From 20fd688d828640a431727057e875f4602804c77c Mon Sep 17 00:00:00 2001 From: vutran1710 Date: Sun, 17 Mar 2024 20:53:30 +0700 Subject: [PATCH] remove clock-exception --- pyrate_limiter/clocks.py | 6 +----- pyrate_limiter/exceptions.py | 6 ------ 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/pyrate_limiter/clocks.py b/pyrate_limiter/clocks.py index aead77b0..9f3eb4cc 100644 --- a/pyrate_limiter/clocks.py +++ b/pyrate_limiter/clocks.py @@ -8,7 +8,6 @@ from typing import TYPE_CHECKING from .abstracts import AbstractClock -from .exceptions import PyrateClockException from .utils import dedicated_sqlite_clock_connection if TYPE_CHECKING: @@ -67,10 +66,7 @@ def now(self) -> int: with conn.cursor() as cur: cur.execute("SELECT EXTRACT(epoch FROM current_timestamp) * 1000") result = cur.fetchone() - - if not result: - raise PyrateClockException(self, detail=f"invalid result from query current-timestamp: {result}") - + assert result, "unable to get current-timestamp from postgres" value = int(result[0]) return value diff --git a/pyrate_limiter/exceptions.py b/pyrate_limiter/exceptions.py index 15fee456..ac84f529 100644 --- a/pyrate_limiter/exceptions.py +++ b/pyrate_limiter/exceptions.py @@ -33,9 +33,3 @@ def __init__(self, item: RateItem, rate: Rate, actual_delay: int, max_delay: int "actual_delay": actual_delay, } super().__init__(error) - - -class PyrateClockException(Exception): - def __init__(self, clock: object, detail=None): - error = f"Clock({repr(clock)}) is failing: {detail}" - super().__init__(error)