Django 1.6 + RabbitMQ 3.2.3 + Celery 3.1.9 - 为啥我的芹菜工人死于:WorkerLostError:工人过早退出:信号11(SIGSEGV)
Posted
技术标签:
【中文标题】Django 1.6 + RabbitMQ 3.2.3 + Celery 3.1.9 - 为啥我的芹菜工人死于:WorkerLostError:工人过早退出:信号11(SIGSEGV)【英文标题】:Django 1.6 + RabbitMQ 3.2.3 + Celery 3.1.9 - why does my celery worker die with: WorkerLostError: Worker exited prematurely: signal 11 (SIGSEGV)Django 1.6 + RabbitMQ 3.2.3 + Celery 3.1.9 - 为什么我的芹菜工人死于:WorkerLostError:工人过早退出:信号11(SIGSEGV) 【发布时间】:2014-03-22 03:14:15 【问题描述】:这似乎解决了一个非常相似的问题,但没有给我足够的洞察力:https://github.com/celery/billiard/issues/101 听起来尝试非 SQLite 数据库可能是个好主意...
我的 django 应用程序有一个简单的 celery 设置。在我的settings.py
文件中,我将任务设置为运行如下:
CELERYBEAT_SCHEDULE =
'sync_database':
'task': 'apps.data.tasks.celery_sync_database',
'schedule': timedelta(minutes=5)
我已按照此处的说明进行操作:http://celery.readthedocs.org/en/latest/django/first-steps-with-django.html
我可以打开两个新的终端窗口并运行 celery 进程,如下所示:
ONE - 计划任务所需的 celery beat 进程,并将任务放入队列:
PROMPT> celery -A myproj beat
celery beat v3.1.9 (Cipater) is starting.
__ - ... __ - _
Configuration ->
. broker -> amqp://myproj@localhost:5672//
. loader -> celery.loaders.app.AppLoader
. scheduler -> djcelery.schedulers.DatabaseScheduler
. logfile -> [stderr]@%INFO
. maxinterval -> now (0s)
[2014-02-20 16:15:20,085: INFO/MainProcess] beat: Starting...
[2014-02-20 16:15:20,086: INFO/MainProcess] Writing entries...
[2014-02-20 16:15:20,143: INFO/MainProcess] DatabaseScheduler: Schedule changed.
[2014-02-20 16:15:20,143: INFO/MainProcess] Writing entries...
[2014-02-20 16:20:20,143: INFO/MainProcess] Scheduler: Sending due task sync_database (apps.data.tasks.celery_sync_database)
[2014-02-20 16:20:20,161: INFO/MainProcess] Writing entries...
TWO - celery worker,应该将任务从队列中取出并运行:
PROMPT> celery -A myproj worker -l info
-------------- celery@Jons-MacBook.local v3.1.9 (Cipater)
---- **** -----
--- * *** * -- Darwin-13.0.0-x86_64-i386-64bit
-- * - **** ---
- ** ---------- [config]
- ** ---------- .> app: myproj:0x1105a1050
- ** ---------- .> transport: amqp://myproj@localhost:5672//
- ** ---------- .> results: djcelery.backends.database:DatabaseBackend
- *** --- * --- .> concurrency: 4 (prefork)
-- ******* ----
--- ***** ----- [queues]
-------------- .> celery exchange=celery(direct) key=celery
[tasks]
. apps.data.tasks.celery_sync_database
. myproj.celery.debug_task
[2014-02-20 16:15:29,402: INFO/MainProcess] Connected to amqp://myproj@127.0.0.1:5672//
[2014-02-20 16:15:29,419: INFO/MainProcess] mingle: searching for neighbors
[2014-02-20 16:15:30,440: INFO/MainProcess] mingle: all alone
[2014-02-20 16:15:30,474: WARNING/MainProcess] celery@Jons-MacBook.local ready.
然而,当任务被发送时,似乎有 50% 的时间工作人员运行任务,而另外 50% 的时间我收到以下错误:
[2014-02-20 16:35:20,159: INFO/MainProcess] Received task: apps.data.tasks.celery_sync_database[960bcb6c-d6a5-4e32-8267-cfbe2b411b25]
[2014-02-20 16:36:54,561: ERROR/MainProcess] Process 'Worker-4' pid:19500 exited with exitcode -11
[2014-02-20 16:36:54,580: ERROR/MainProcess] Task apps.data.tasks.celery_sync_database[960bcb6c-d6a5-4e32-8267-cfbe2b411b25] raised unexpected: WorkerLostError('Worker exited prematurely: signal 11 (SIGSEGV).',)
Traceback (most recent call last):
File "/Users/jon/dev/vpe/VAN/lib/python2.7/site-packages/billiard/pool.py", line 1168, in mark_as_worker_lost
human_status(exitcode)),
WorkerLostError: Worker exited prematurely: signal 11 (SIGSEGV).
我正在运行 Mavericks 的 Macbook Pro 上进行开发。
Celery 版本 3.1.9 兔MQ 3.2.3 Django 1.6
请注意,我使用的是 django-celery 3.1.9 并启用了 djcelery 应用程序。
【问题讨论】:
【参考方案1】:当我从 SQLite 切换到 PostgreSQL 时,问题就消失了。
【讨论】:
以上是关于Django 1.6 + RabbitMQ 3.2.3 + Celery 3.1.9 - 为啥我的芹菜工人死于:WorkerLostError:工人过早退出:信号11(SIGSEGV)的主要内容,如果未能解决你的问题,请参考以下文章