意见箱
恒创运营部门将仔细参阅您的意见和建议,必要时将通过预留邮箱与您保持联络。感谢您的支持!
意见/建议
提交建议

python连接池interfaceerror

来源:佚名 编辑:佚名
2024-06-20 14:10:46

Unfortunately this is a problem with django + psycopg2 + celery combo.

It's an old and unsolved problem.

Take a look on this thread to understand:


python连接池interfaceerror

https://github.com/celery/django-celery/issues/121

Basically, when celery starts a worker, it forks a database connection

from django.db framework. If this connection drops for some reason, it

doesn't create a new one. Celery has nothing to do with this problem

once there is no way to detect when the database connection is dropped

using django.db libraries. Django doesn't notifies when it happens,

because it just start a connection and it receives a wsgi call (no

connection pool). I had the same problem on a huge production

environment with a lot of machine workers, and sometimes, these

machines lost connectivity with postgres server.

I solved it putting each celery master process under a linux

supervisord handler and a watcher and implemented a decorator that

handles the psycopg2.InterfaceError, and when it happens this function

dispatches a syscall to force supervisor restart gracefully with

SIGINT the celery process.

本网站发布或转载的文章均来自网络,其原创性以及文中表达的观点和判断不代表本网站。
上一篇: python socket连接问题 下一篇: Python局域网socket无法连接的问题解决