fix
This commit is contained in:
parent
a328d6feb2
commit
5efc884f12
@ -3,7 +3,7 @@ import pydantic
|
||||
import typing
|
||||
|
||||
from app.storage.mongo import tasks
|
||||
from app.storage.redis import lock
|
||||
from app.storage import redis
|
||||
|
||||
|
||||
router = fastapi.APIRouter()
|
||||
@ -17,7 +17,7 @@ class Response(pydantic.BaseModel):
|
||||
|
||||
@router.get('/api/v1/take', responses={404: {'description': 'Not found'}})
|
||||
async def execute(queue: typing.Annotated[str, fastapi.Header()]) -> Response:
|
||||
async with lock.acquire(queue):
|
||||
async with redis.database.lock(queue):
|
||||
task = await tasks.take_task(queue)
|
||||
if not task:
|
||||
raise fastapi.HTTPException(404)
|
||||
|
@ -1,4 +1,3 @@
|
||||
import asyncio
|
||||
import bson
|
||||
import datetime
|
||||
import pydantic
|
||||
|
@ -1,5 +1,5 @@
|
||||
import os
|
||||
import redis.asyncio
|
||||
import redis.asyncio as connection
|
||||
|
||||
|
||||
REDIS_HOST = os.getenv('REDIS_HOST', 'localhost')
|
||||
@ -11,5 +11,5 @@ else:
|
||||
|
||||
|
||||
|
||||
pool = redis.asyncio.ConnectionPool.from_url(URL)
|
||||
database = redis.Redis.from_pool(pool)
|
||||
pool = connection.from_url(URL)
|
||||
database = connection.Redis.from_pool(pool)
|
||||
|
@ -1,8 +0,0 @@
|
||||
import contextlib
|
||||
|
||||
from app.storage import redis
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def acquire(lock_name: str):
|
||||
return redis.database.lock(lock_name)
|
Loading…
Reference in New Issue
Block a user