Queue long-running backup and upload

This commit is contained in:
2026-02-07 22:55:34 +03:00
parent 69ace93cac
commit 77801e9123
4 changed files with 37 additions and 12 deletions

19
services/queue.py Normal file
View File

@@ -0,0 +1,19 @@
import asyncio
from typing import Awaitable, Callable
_queue: asyncio.Queue = asyncio.Queue()
async def enqueue(job: Callable[[], Awaitable[None]]) -> int:
await _queue.put(job)
return _queue.qsize()
async def worker():
while True:
job = await _queue.get()
try:
await job()
finally:
_queue.task_done()