Compare commits
No commits in common. "875294bdd760d1e7308e396a65ca2ab3473b5fac" and "6bcd8375e8ca9c4134a8466d27fe9aabd794453d" have entirely different histories.
875294bdd7
...
6bcd8375e8
@ -8,6 +8,4 @@ RUN pip install -r requirements.txt
|
||||
|
||||
COPY . .
|
||||
|
||||
ENV PYTHONUNBUFFERED 1
|
||||
|
||||
ENTRYPOINT ["python", "main.py"]
|
||||
|
@ -1,3 +1,5 @@
|
||||
import asyncio
|
||||
import collections
|
||||
import fastapi
|
||||
import pydantic
|
||||
import typing
|
||||
@ -7,6 +9,7 @@ from app.storage.mongo import tasks
|
||||
|
||||
|
||||
DEFAULT_RETRY_AFTER = 0.2
|
||||
locks = collections.defaultdict(asyncio.Lock)
|
||||
router = fastapi.APIRouter()
|
||||
|
||||
|
||||
@ -20,13 +23,10 @@ class Response(pydantic.BaseModel):
|
||||
task: Task|None
|
||||
|
||||
|
||||
@router.get('/api/v1/take')
|
||||
@router.get('/api/v1/take', responses={500: {'detail': 'Internal server error'}})
|
||||
async def execute(queue: typing.Annotated[str, fastapi.Header()]) -> Response:
|
||||
try:
|
||||
async with locks[queue]:
|
||||
task = await tasks.take_task(queue)
|
||||
except Exception as e:
|
||||
print('GOT ERROR', e)
|
||||
return Response(task=None)
|
||||
if not task:
|
||||
return Response(task=None)
|
||||
# retry_after_config = configurator.get_config('retry_after')
|
||||
|
Loading…
Reference in New Issue
Block a user