Skip to content

Commit 3809a1c

Browse files
ashokDevsclaude
andcommitted
fix: add missing acquire_lock and release_lock to redis_service
These functions are used for atomic job creation but were never defined. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1ec623a commit 3809a1c

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

backend/services/redis_service.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,23 @@
1515
priority_queue = Queue("high", connection=redis_client)
1616

1717

18+
def acquire_lock(key: str, timeout: int = 10):
19+
try:
20+
return redis_client.set(key, "1", nx=True, ex=timeout)
21+
except Exception as e:
22+
logger.error("redis_acquire_lock_failed", key=key, error=str(e))
23+
return False
24+
25+
26+
def release_lock(key: str):
27+
try:
28+
redis_client.delete(key)
29+
return True
30+
except Exception as e:
31+
logger.error("redis_release_lock_failed", key=key, error=str(e))
32+
return False
33+
34+
1835
def set_cache(key: str, value: str, expire: int = None):
1936
try:
2037
redis_client.set(key, value, ex=expire)

0 commit comments

Comments
 (0)