gpt4 book ai didi

django - redis.异常.LockError : Cannot release an unlocked lock after restarting celerybeat

转载 作者:IT王子 更新时间:2023-10-29 06:12:50 28 4
gpt4 key购买 nike

有时在重新启动 celerybeat 后,我​​会收到以下错误,我已将 celerybeat 设置为带有 redis 的服务,

sude service celerybeat restart

下面是异常轨迹

Traceback (most recent call last):
File "/home/ec2-user/pyenv/local/lib/python3.4/site-packages/celery/beat.py", line 484, in start
time.sleep(interval)
File "/home/ec2-user/pyenv/local/lib/python3.4/site-packages/celery/apps/beat.py", line 148, in _sync
beat.sync()
File "/home/ec2-user/pyenv/local/lib/python3.4/site-packages/celery/beat.py", line 493, in sync
self.scheduler.close()
File "/home/ec2-user/pyenv/local/lib/python3.4/site-packages/redbeat/schedulers.py", line 272, in close
self.lock.release()
File "/home/ec2-user/pyenv/local/lib/python3.4/site-packages/redis/lock.py", line 135, in release
self.do_release(expected_token)
File "/home/ec2-user/pyenv/local/lib/python3.4/site-packages/redis/lock.py", line 264, in do_release
raise LockError("Cannot release a lock that's no longer owned")
redis.exceptions.LockError: Cannot release a lock that's no longer owned

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/ec2-user/pyenv/local/lib/python3.4/site-packages/celery/apps/beat.py", line 112, in start_scheduler
beat.start()
File "/home/ec2-user/pyenv/local/lib/python3.4/site-packages/celery/beat.py", line 490, in start
self.sync()
File "/home/ec2-user/pyenv/local/lib/python3.4/site-packages/celery/beat.py", line 493, in sync
self.scheduler.close()
File "/home/ec2-user/pyenv/local/lib/python3.4/site-packages/redbeat/schedulers.py", line 272, in close
self.lock.release()
File "/home/ec2-user/pyenv/local/lib/python3.4/site-packages/redis/lock.py", line 133, in release
raise LockError("Cannot release an unlocked lock")
redis.exceptions.LockError: Cannot release an unlocked lock

异常不会每次都发生,我没有注意到由此引起的任何问题,celerybeat 即使在这个异常之后也能正常工作。既然是生产环境,就想安心处理。

最佳答案

我在我的日志中注意到了同样的情况,对我来说原因是 redis 超时时间比任务花费的时间短,所以它试图在它过期后释放一个锁,例如:

with redis_client.lock('some_key', timeout=5):
time.sleep(10)

给出

redis.exceptions.LockError: Cannot release a lock that's no longer owned

关于django - redis.异常.LockError : Cannot release an unlocked lock after restarting celerybeat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52282271/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com