mirror of
https://github.com/nexy7574/LCC-bot.git
synced 2024-09-19 18:16:34 +01:00
Show cleanup stats
This commit is contained in:
parent
42682c6378
commit
2eb9adee7b
1 changed files with 3 additions and 0 deletions
|
@ -72,9 +72,12 @@ async def authenticate(req: Request, code: str = None, state: str = None):
|
||||||
if value in app.state.states:
|
if value in app.state.states:
|
||||||
print("Generated a state that already exists. Cleaning up", file=sys.stderr)
|
print("Generated a state that already exists. Cleaning up", file=sys.stderr)
|
||||||
# remove any states older than 5 minutes
|
# remove any states older than 5 minutes
|
||||||
|
removed = 0
|
||||||
for _value in list(app.state.states):
|
for _value in list(app.state.states):
|
||||||
if (datetime.now() - app.state.states[_value]).total_seconds() > 300:
|
if (datetime.now() - app.state.states[_value]).total_seconds() > 300:
|
||||||
del app.state.states[_value]
|
del app.state.states[_value]
|
||||||
|
removed += 1
|
||||||
|
print(f"Removed {removed} states.", file=sys.stderr)
|
||||||
|
|
||||||
if value in app.state.states:
|
if value in app.state.states:
|
||||||
assert value not in app.state.states, "Generated a state that already exists and could not free any slots."
|
assert value not in app.state.states, "Generated a state that already exists and could not free any slots."
|
||||||
|
|
Loading…
Reference in a new issue