mirror of
https://github.com/rommapp/romm.git
synced 2026-11-28 17:48:31 +01:00
endpoints/streaming.py had grown to 3778 lines, but only about a third of that was routes. The rest was a second copy of the layer handler/streaming already exists to hold: broker verbs, webstation protocol translation, state and save and memory-card transfer, session teardown. Split it along those seams rather than by route, and give claim_session the same treatment: its 406 lines are now four named phases. Cross-module calls go through the module (states.pull_state_to_library, commands.stop) instead of imported names, so one definition site is what tests patch and what every caller reads. No route path, scope or response model changed, so the OpenAPI schema is untouched. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
14 lines
350 B
Python
14 lines
350 B
Python
"""Fire-and-forget sync tasks, held so the event loop keeps them alive."""
|
|
|
|
import asyncio
|
|
from typing import Any
|
|
|
|
_sync_tasks: set[asyncio.Task] = set()
|
|
|
|
|
|
def spawn_sync_task(coro: Any) -> asyncio.Task:
|
|
task = asyncio.get_running_loop().create_task(coro)
|
|
_sync_tasks.add(task)
|
|
task.add_done_callback(_sync_tasks.discard)
|
|
return task
|