fix
This commit is contained in:
parent
acfbb98e31
commit
a55baa613c
@ -25,5 +25,5 @@ class Response(pydantic.BaseModel):
|
||||
async def execute(queue: typing.Annotated[str, fastapi.Header()]) -> Response:
|
||||
task = await tasks.take_task(queue)
|
||||
if not task:
|
||||
raise fastapi.HTTPException(404)
|
||||
return Response(id=str(task._id), attempt=task.attempts, payload=task.payload, task=Task(id=str(task._id), attempt=task.attempts, payload=task.payload))
|
||||
return Response(task=None)
|
||||
return Response(task=Task(id=str(task._id), attempt=task.attempts, payload=task.payload))
|
||||
|
@ -1,7 +1,6 @@
|
||||
import bson
|
||||
import datetime
|
||||
import pydantic
|
||||
import typing
|
||||
|
||||
from app.storage.mongo import database
|
||||
from app.utils import time
|
||||
@ -27,7 +26,7 @@ async def add_task(task: Task) -> str:
|
||||
return result.inserted_id
|
||||
|
||||
|
||||
async def take_task(queue: str) -> typing.Optional[Task]:
|
||||
async def take_task(queue: str) -> Task|None:
|
||||
now = time.now()
|
||||
async for raw_task in collection.find({'queue': queue, 'available_from': {'$lte': now}}):
|
||||
task = Task.model_validate(raw_task)
|
||||
|
Loading…
Reference in New Issue
Block a user