Skip to content

Commit 1cbaf7f

Browse files
committed
Fixes, updated types
1 parent a77c137 commit 1cbaf7f

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/lightspeed_stack.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def main() -> None:
124124
# start the runners
125125
start_quota_scheduler(configuration.configuration)
126126
# if every previous steps don't fail, start the service on specified port
127-
start_uvicorn(configuration.service_configuration)
127+
start_uvicorn(configuration.service_configuration)
128128
logger.info("Lightspeed Core Stack finished")
129129

130130

src/runners/quota_scheduler.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def quota_scheduler(config: QuotaHandlersConfiguration) -> bool:
8080
for limiter in config.limiters:
8181
try:
8282
quota_revocation(connection, limiter)
83-
except Exception as e:
83+
except Exception as e: # pylint: disable=broad-exception-caught)
8484
logger.error("Quota revoke error: %s", e)
8585
logger.info("Quota scheduler sync finished")
8686
sleep(period)
@@ -89,9 +89,7 @@ def quota_scheduler(config: QuotaHandlersConfiguration) -> bool:
8989
return True
9090

9191

92-
def quota_revocation(
93-
connection: Any, quota_limiter: QuotaLimiterConfiguration
94-
) -> None:
92+
def quota_revocation(connection: Any, quota_limiter: QuotaLimiterConfiguration) -> None:
9593
"""Quota revocation mechanism."""
9694
logger.info(
9795
"Quota revocation mechanism for limiter '%s' of type '%s'",
@@ -100,10 +98,10 @@ def quota_revocation(
10098
)
10199

102100
if quota_limiter.type is None:
103-
raise Exception("Limiter type not set, skipping revocation")
101+
raise ValueError("Limiter type not set, skipping revocation")
104102

105103
if quota_limiter.period is None:
106-
raise Exception("Limiter period not set, skipping revocation")
104+
raise ValueError("Limiter period not set, skipping revocation")
107105

108106
subject_id = get_subject_id(quota_limiter.type)
109107

@@ -184,6 +182,7 @@ def connect(config: QuotaHandlersConfiguration) -> Any:
184182
return connect_pg(config.postgres)
185183
if config.sqlite is not None:
186184
return connect_sqlite(config.sqlite)
185+
return None
187186

188187

189188
def connect_pg(config: PostgreSQLDatabaseConfiguration) -> Any:
@@ -203,7 +202,8 @@ def connect_pg(config: PostgreSQLDatabaseConfiguration) -> Any:
203202
connection.autocommit = True
204203
return connection
205204

206-
def connect_sqlite(config: SQLiteDatabaseConfiguration) -> None:
205+
206+
def connect_sqlite(config: SQLiteDatabaseConfiguration) -> Any:
207207
"""Initialize connection to database."""
208208
logger.info("Connecting to SQLite storage")
209209
# make sure the connection will have known state

0 commit comments

Comments
 (0)