Autoformat with black
This commit is contained in:
parent
5ca9b3f9e9
commit
03b46d2bd5
2 changed files with 15 additions and 7 deletions
|
@ -722,7 +722,7 @@ async def handle_search(sid: str, data: dict[str, Any]) -> None:
|
|||
|
||||
|
||||
async def cleanup() -> None:
|
||||
""" Clean up the unused playback clients
|
||||
"""Clean up the unused playback clients
|
||||
|
||||
This runs every hour, and removes every client, that did not requested a song for four hours
|
||||
"""
|
||||
|
@ -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,10 +753,15 @@ 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]:
|
||||
""" Create all the background tasks
|
||||
|
||||
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.
|
||||
|
|
|
@ -35,7 +35,7 @@ class FilesSource(Source):
|
|||
for file in files:
|
||||
if file.endswith(".cdg"):
|
||||
file_list.append(
|
||||
os.path.join(path, file)[len(self.dir):]
|
||||
os.path.join(path, file)[len(self.dir) :]
|
||||
)
|
||||
return file_list
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue