2013-05-12 30 views
0

我使用的是芹菜和Django的集成。我發現了一些新項目給我目前的項目帶來的一些麻煩:帶有gevent池的芹菜工人拒絕處理新的任務。短暫調查後,我發現,「哨兵」日誌處理程序導致一個問題: settings.py:芹菜工作者GEVENT池+哨兵記錄=掛

LOGGING = { 
    'version': 1, 
    'disable_existing_loggers': False, 
    'filters': { 
     'require_debug_false': { 
      '()': 'django.utils.log.RequireDebugFalse' 
     } 
    }, 
    'formatters': { 
     'verbose': { 
      'format': '%(levelname)s %(asctime)s %(module)s '\ 
         '%(process)d %(thread)d %(message)s' 
     }, 
     'gunicorn_style': { 
      'format': CELERYD_TASK_LOG_FORMAT, 
      }, 
    }, 
    'handlers': { 
     'console':{ 
      'level': 'DEBUG', 
      'class': 'logging.StreamHandler', 
      'formatter': 'gunicorn_style' 
     }, 
     'mail_admins': { 
      'level': 'ERROR', 
      'filters': ['require_debug_false'], 
      'class': 'django.utils.log.AdminEmailHandler' 
     }, 
     'sentry': { 
      'level': 'WARNING', 
      'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler', 
     } 
}, 
'loggers': { 
    'django.request': { 
     'handlers': ['mail_admins'], 
     'level': 'ERROR', 
     'propagate': True, 
    }, 
    'raven': { 
     'level': 'INFO', 
     'handlers': ['console'], 
     'propagate': False, 
    }, 
    'sentry.errors': { 
     'level': 'INFO', 
     'handlers': ['console'], 
     'propagate': False, 
     }, 
    } 
} 
... 
#I want verbose logs only for my apps 
for i in MY_APPS: 
    LOGGING['loggers'][i] = { 
          'handlers': ['console', 'sentry'], 
          'level': CONSOLE_LOGLEVEL, 
          'propagate': False, 
          } 
LOGGING['loggers']['celery'] = { 
          'handlers': ['sentry'], 
          'level': CONSOLE_LOGLEVEL, 
          'propagate': True, 
          } 
... 

隨着「處理」:「控制檯」]一切工作正常,但是當我加上「哨兵」處理程序CELER + GEVENT工人開始表現如下:從券商,其中N爲併發級別,然後停止採取N個任務。

我運行芹菜工人用這個命令:

python manage.py celery worker -Q celery_gevent -P gevent -c 20  

注:deathlock示出了具有併發> = 3

$ pip freeze 
Django==1.5 
Fabric==1.6.0 
South==0.7.6 
amqp==1.0.9 
anyjson==0.3.3 
argparse==1.2.1 
billiard==2.7.3.22 
celery==3.0.16 
cssselect==0.8 
distribute==0.6.24 
django-appconf==0.6 
django-celery==3.0.11 
django-geoip==0.3 
django-nose==1.1 
django-redis==3.2 
flower==0.5.0 
gevent==0.13.8 
greenlet==0.4.0 
gunicorn==0.17.2 
ipython==0.13.1 
kombu==2.5.7 
logilab-astng==0.24.2 
logilab-common==0.59.0 
lxml==3.1.1 
nose==1.2.1 
paramiko==1.10.0 
progressbar==2.3dev 
psycopg2==2.4.6 
pycrypto==2.6 
pylint==0.27.0 
pymongo==2.4.2 
python-dateutil==1.5 
pytz==2013b 
raven==3.2.0 
redis==2.7.2 
requests==1.0.4 
six==1.3.0 
tornado==3.0.1 
wsgiref==0.1.2 

我使用的RabbitMQ作爲經紀人和redis的作爲結果的後端

謝謝。

P.S.同步芹菜工人正常工作與任何配置

回答