feat: deadlock clear
This commit is contained in:
@@ -26,7 +26,6 @@ class BatchLimiter:
|
||||
async def acquire(self, key, max_requests, period):
|
||||
redis = await RedisConnectionManager.get_redis_connection()
|
||||
while True:
|
||||
logging.info(f'Getting key: {key}')
|
||||
async with redis.lock(f"{key}_lock"):
|
||||
try:
|
||||
start_time = await redis.get(f"{key}:start_time")
|
||||
@@ -56,6 +55,13 @@ class BatchLimiter:
|
||||
logging.error(f"Redis error: {e}")
|
||||
await asyncio.sleep(1)
|
||||
|
||||
async def clear_locks(self):
|
||||
redis = await RedisConnectionManager.get_redis_connection()
|
||||
keys = []
|
||||
async for key in redis.scan_iter('*_lock*'):
|
||||
keys.append(key)
|
||||
await redis.delete(*keys)
|
||||
|
||||
async def acquire_wildberries(self, key):
|
||||
max_requests = 300
|
||||
period = 60
|
||||
|
||||
Reference in New Issue
Block a user