Archived
Add formatting and type checks
This commit is contained in:
1 parent
c0d82eaf26
commit
24747866bc
38 files changed
+800
-265
No files matched your search
@@ -1,14 +1,23 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import threading
|
||||
import time
|
||||
from datetime import UTC, datetime, timedelta
|
||||
|
||||
from .types import CleanupRunRow
|
||||
from .base import StoreConnectionMixin
|
||||
from .types import CleanupRunRow, cleanup_run_row
|
||||
|
||||
RATE_LIMIT_FLUSH_SECONDS = 10.0
|
||||
|
||||
|
||||
class RateLimitCleanupMixin:
|
||||
class RateLimitCleanupMixin(StoreConnectionMixin):
|
||||
_rate_limit_lock: threading.Lock
|
||||
_rate_limit_prune_lock: threading.Lock
|
||||
_rate_limit_buckets: dict[str, dict[str, float | int]]
|
||||
_rate_limit_dirty_counts: dict[tuple[str, int], int]
|
||||
_last_rate_limit_flush: float
|
||||
_last_rate_limit_prune_window: int
|
||||
|
||||
def list_cleanup_runs(self, limit: int = 20, offset: int = 0) -> list[CleanupRunRow]:
|
||||
with self.connect() as conn:
|
||||
rows = conn.execute(
|
||||
@@ -20,7 +29,7 @@ class RateLimitCleanupMixin:
|
||||
""",
|
||||
(limit, offset),
|
||||
).fetchall()
|
||||
return [CleanupRunRow(**dict(row)) for row in rows]
|
||||
return [cleanup_run_row(row) for row in rows]
|
||||
|
||||
def count_cleanup_runs(self) -> int:
|
||||
with self.connect() as conn:
|
||||
|
||||
Reference in new issue
Block a user