從芹菜2.4.5升級後,我開始讓芹菜隨機關機。
我使用芹菜3.0.12,博託2.6和Amazon SQS和Django的1.2.7這一切CentOS的機器上(PIP底部凍結轉儲)芹菜關機
我運行
service celerybeat start
service celeryd start
數秒鐘後我開始芹菜停止(關機),如果我看着芹菜日誌之一,我總是看到這一點:
[2012-12-31 10:13:40,275: INFO/MainProcess] Task patrol.tasks.test[270f1558-bcc2-441b-8961 e1f21a2dbd27] succeeded in 0.318082094193s: None
[2012-12-31 10:13:40,424: INFO/MainProcess] child process calling self.run()
[2012-12-31 10:13:40,428: INFO/MainProcess] Got task from broker: patrol.tasks.myTask[d9a5ab26-71ca-448b-a4da-40315570f219]
[2012-12-31 10:13:40,666: INFO/MainProcess] Got task from broker: tasks.test[99edb7e2-caff-4892-a95b-c18a9d7f5c51]
[2012-12-31 10:13:41,114: WARNING/MainProcess] Restoring 2 unacknowledged message(s).
[2012-12-31 10:13:41,115: WARNING/MainProcess] UNABLE TO RESTORE 2 MESSAGES: (TypeError('<boto.sqs.message.Message instance at 0x3269758> is not JSON serializable',), TypeError('<boto.sqs.message.Message instance at 0x32697e8> is not JSON serializable',))
[2012-12-31 10:13:41,116: WARNING/MainProcess] EMERGENCY DUMP STATE TO FILE -> /tmp/tmppO4Bbp <-
[2012-12-31 10:13:41,116: WARNING/MainProcess] Cannot pickle state: TypeError('a class that defines __slots__ without defining __getstate__ cannot be pickled',). Fallback to pformat.
我用使用低值maxtaskperchild快速重新創建關機。如果我給一個更高的值,那麼關機前需要更長的時間。
編輯
在試圖隔離問題我刪除了所有的週期性任務。現在我只有一項週期性任務和一項基本無所作爲的任務,但我仍然可以每次重現錯誤。
@task
def myTask():
print 1
return
class test(PeriodicTask):
run_every = datetime.timedelta(seconds=3)
def run(self, **kwargs):
myTask.delay()
print '2'
我/init.d/celeryd
我/默認/ celeryd
# Name of nodes to start, here we have a single node
# or we could have three nodes:
CELERYD_NODES="w1 w2"
CELERYD_LOG_LEVEL="INFO"
# Where to chdir at start.
CELERYD_CHDIR="/var/myproject"
# How to call "manage.py celeryd_multi"
CELERYD_MULTI="python $CELERYD_CHDIR/manage.py celeryd_multi"
# How to call "manage.py celeryctl"
CELERYCTL="python $CELERYD_CHDIR/manage.py celeryctl"
MAXTASKPERCHILD=2 # this is low on purpose to recreate the shutdown fast
CELERY_CONC=5
EXPRESS_CONC=2
# Extra arguments to celeryd
CELERYD_OPTS="-Q:w1 celery,backup -c:w1 $CELERY_CONC -Q:w2 express -c:w2 $EXPRESS_CONC --time-limit=3600 --maxtasksperchild=$MAXTASKPERCHILD -E"
# Name of the celery config module.
CELERY_CONFIG_MODULE="celeryconfig"
# %n will be replaced with the nodename.
CELERYD_LOG_FILE="/var/log/celeryd/%n.log"
CELERYD_PID_FILE="/var/run/celeryd/%n.pid"
# Name of the projects settings module.
export DJANGO_SETTINGS_MODULE="settings"
# Path to celerybeat
CELERYBEAT="python $CELERYD_CHDIR/manage.py celerybeat"
# Extra arguments to celerybeat. This is a file that will get
# created for scheduled tasks. It's generated automatically
# when Celerybeat starts.
CELERYBEAT_OPTS="--schedule=/var/run/celerybeat-schedule"
# Log level. Can be one of DEBUG, INFO, WARNING, ERROR or CRITICAL.
CELERYBEAT_LOG_LEVEL="INFO"
# Log file locations
CELERYBEAT_LOGFILE="/var/log/celeryd/celerybeat.log"
CELERYBEAT_PIDFILE="/var/run/celeryd/celerybeat.pid"
我的點子凍結
Django==1.2.7
M2Crypto==0.20.2
MySQL-python==1.2.3c1
amqp==1.0.6
amqplib==1.0.2
anyjson==0.3.3
billiard==2.7.3.19
boto==2.1.1
celery==3.0.12
certifi==0.0.6
distribute==0.6.10
django-celery==3.0.11
django-kombu==0.9.4
django-picklefield==0.3.0
ghettoq==0.4.5
importlib==1.0.2
iniparse==0.3.1
ipython==0.12
kombu==2.5.4
lxml==2.3.4
mixpanel-celery==0.5.0
netaddr==0.7.6
numpy==1.6.2
odict==1.4.4
ordereddict==1.1
pycrypto==2.6
pycurl==7.19.0
pygooglechart==0.3.0
pygpgme==0.1
python-dateutil==1.5
python-memcached==1.48
pytz==2012h
requests==0.9.0
six==1.2.0
urlgrabber==3.9.1
yum-metadata-parser==1.1.2
把消息後發生它已經關閉,即使我讓它不重新排隊的消息仍然關機。 – yossi
Celery將兔子隊列中的消息從fistly讀取爲消息,您會看到意外任務格式的異常。在rabbitmq或sqs中檢查您的隊列條目 – Rustem
嘗試關閉時發生josn錯誤。代碼在kombu的close方法中https://github.com/celery/kombu/blob/master/kombu/transport/virtual/__init__.py – yossi