Compare commits
No commits in common. "0e1dd5d44e4c7fbcf5a8a233da9eccc2cb32a997" and "1d92f9564953690ccd6db90c0e49d22dcbe7095e" have entirely different histories.
0e1dd5d44e
...
1d92f95649
@ -1,5 +1,3 @@
|
|||||||
import asyncio
|
|
||||||
import collections
|
|
||||||
import fastapi
|
import fastapi
|
||||||
import pydantic
|
import pydantic
|
||||||
import typing
|
import typing
|
||||||
@ -7,7 +5,6 @@ import typing
|
|||||||
from app.storage.mongo import tasks
|
from app.storage.mongo import tasks
|
||||||
|
|
||||||
|
|
||||||
locks = collections.defaultdict(asyncio.Lock)
|
|
||||||
router = fastapi.APIRouter()
|
router = fastapi.APIRouter()
|
||||||
|
|
||||||
|
|
||||||
@ -23,7 +20,6 @@ class Response(pydantic.BaseModel):
|
|||||||
|
|
||||||
@router.get('/api/v1/take', responses={404: {'description': 'Not found'}})
|
@router.get('/api/v1/take', responses={404: {'description': 'Not found'}})
|
||||||
async def execute(queue: typing.Annotated[str, fastapi.Header()]) -> Response:
|
async def execute(queue: typing.Annotated[str, fastapi.Header()]) -> Response:
|
||||||
async with locks[queue]:
|
|
||||||
task = await tasks.take_task(queue)
|
task = await tasks.take_task(queue)
|
||||||
if not task:
|
if not task:
|
||||||
return Response(task=None)
|
return Response(task=None)
|
||||||
|
Loading…
Reference in New Issue
Block a user