Autoformat with black

This commit is contained in:
Christoph Stahl 2023-03-23 15:16:36 +01:00
parent 5ca9b3f9e9
commit 03b46d2bd5
2 changed files with 15 additions and 7 deletions

View file

@ -731,7 +731,10 @@ async def cleanup() -> None:
to_remove: list[str] = []
for sid, state in clients.items():
logger.info("Client %s, last seen: %s", sid, str(state.last_seen))
if state.last_seen + datetime.timedelta(hours=4) < datetime.datetime.now():
if (
state.last_seen + datetime.timedelta(hours=4)
< datetime.datetime.now()
):
logger.info("No activity for 4 hours, removing %s", sid)
to_remove.append(sid)
for sid in to_remove:
@ -739,7 +742,6 @@ async def cleanup() -> None:
del clients[sid]
logger.info("End Cleanup")
# The internal loop counter does not use a regular timestamp, so we need to convert between
# regular datetime and the async loop time
now = datetime.datetime.now()
@ -751,9 +753,14 @@ async def cleanup() -> None:
loop_next = asyncio.get_event_loop().time() + offset
logger.info("Next Cleanup at %s", str(next))
asyncio.get_event_loop().call_at(loop_next, lambda: asyncio.create_task(cleanup()))
asyncio.get_event_loop().call_at(
loop_next, lambda: asyncio.create_task(cleanup())
)
async def background_tasks(iapp: web.Application) -> AsyncGenerator[None, None]:
async def background_tasks(
iapp: web.Application,
) -> AsyncGenerator[None, None]:
"""Create all the background tasks
For now, this is only the cleanup task
@ -766,6 +773,7 @@ async def background_tasks(iapp: web.Application) -> AsyncGenerator[None, None]:
iapp["repeated_cleanup"].cancel()
await iapp["repeated_cleanup"]
def main() -> None:
"""
Configure and start the server.