from app.adapters.redis import redis_client from app.config import settings def acquire(batch_id: int) -> None: """Set the per-batch lock, as the dispatcher does before invoking us.""" redis_client.set(settings.redis_sender_lock_key.format(batch_id=batch_id), "1") def release(batch_id: int) -> None: """Release the per-batch Redis lock the dispatcher set before invoking us.""" redis_client.delete(settings.redis_sender_lock_key.format(batch_id=batch_id))