django-celery 管理命令给出 AttributeError: '_multiprocessing.SemLock' 对象没有属性 'name'

Posted

技术标签:

【中文标题】django-celery 管理命令给出 AttributeError: \'_multiprocessing.SemLock\' 对象没有属性 \'name\'【英文标题】:django-celery managment command giving AttributeError: '_multiprocessing.SemLock' object has no attribute 'name'django-celery 管理命令给出 AttributeError: '_multiprocessing.SemLock' 对象没有属性 'name' 【发布时间】:2012-09-25 10:11:45 【问题描述】:

我想向管理员发送通知电子邮件,例如,如果帖子是垃圾邮件,那么管理员应该收到电子邮件。 我正在使用 django-celery templated_email 和 kombu。 但是当我运行 djcelery 的任何管理命令时出现错误

D:\test\testapp>python manage.py celeryd -l info C:\Python27\lib\site-packages\django_celery-3.0.4-py2.7.egg\djcelery\loaders.py:116: UserWarning:使用 settings.DEBUG 会导致内存泄漏,n warnings.warn("使用 settings.DEBUG 会导致内存泄漏,永远不会"

 -------------- celery@Siddhatech_A-PC v3.0.4 (Chiastic Slide)
  ---- **** -----
 --- * ***  * -- [Configuration]
 -- * - **** --- . broker:      djkombu.transport.DatabaseTransport://localhost//
 - ** ---------- . app:         default:0x28c3390 (djcelery.loaders.DjangoLoader)
 - ** ---------- . concurrency: 4 (processes)
 - ** ---------- . events:      OFF (enable -E to monitor this worker)
 - ** ----------
 - *** --- * --- [Queues]
 -- ******* ---- . celery:      exchange:celery(direct) binding:celery
 --- ***** ----- . email:       exchange:celery(direct) binding:email

  [Tasks]
    . djcelery_email_send
    . testapp.tasks.add

Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:\Python27\lib\site-packages\billiard-2.7.3.10-py2.7-billiard\forking.py", line 496, in main
     self = load(from_parent)
    File "C:\Python27\lib\pickle.py", line 1378, in load
    return Unpickler(file).load()
    File "C:\Python27\lib\pickle.py", line 858, in load
   [2012-10-04 14:45:25,960: ERROR/MainProcess]Unrecoverable error:AttributeError("'_multiprocessing.SemLock' object has no attribute 'name'",)
   Traceback (most recent call last):
   File "C:\Python27\lib\site-packages\celery-3.0.4-py2.7.egg\celery\worker\__init__.py", line 348, in start
   component.start()
   File "C:\Python27\lib\site-packages\celery-3.0.4-py2.7.egg\celery\concurrency\base.py", line 109, in start
   self.on_start()
   File "C:\Python27\lib\site-packages\celery-3.0.4-py2.7.egg\celery\concurrency\processes\__init__.py", line 84, in on_start
   **self.options)
   File "C:\Python27\lib\site-packages\billiard-2.7.3.10-py2.7-win32.egg\billiard\pool.py", line 799, in __init__
   self._create_worker_process()
   File "C:\Python27\lib\site-packages\billiard-2.7.3.10-py2.7-win32.egg\billiard\pool.py", line 867, in _create_worker_process
   w.start()
   File "C:\Python27\lib\site-packages\billiard-2.7.3.10-py2.7-win32.egg\billiard\process.py", line 138, in start
   self._popen = Popen(self)
   File "C:\Python27\lib\site-packages\billiard-2.7.3.10-py2.7-win32.egg\billiard\forking.py", line 350, in __init__
   dump(process_obj, to_child, HIGHEST_PROTOCOL)
   File "C:\Python27\lib\site-packages\billiard-2.7.3.10-py2.7-win32.egg\billiard\forking.py", line 143, in dump
   ForkingPickler(file, protocol).dump(obj)
   File "C:\Python27\lib\pickle.py", line 224, in dump
   self.save(obj)
   File "C:\Python27\lib\pickle.py", line 331, in save
   self.save_reduce(obj=obj, *rv)
   File "C:\Python27\lib\pickle.py", line 419, in save_reduce
   save(state)
   File "C:\Python27\lib\pickle.py", line 286, in savef(self, obj) # Call unbound method with explicit self
   File "C:\Python27\lib\pickle.py", line 649, in save_dict
   self._batch_setitems(obj.iteritems())
   File "C:\Python27\lib\pickle.py", line 681, in _batch_setitems
   save(v)
   File "C:\Python27\lib\pickle.py", line 286, in save
   f(self, obj) # Call unbound method with explicit self
   File "C:\Python27\lib\pickle.py", line 562, in save_tuple
   save(element)
   File "C:\Python27\lib\pickle.py", line 331, in save
   self.save_reduce(obj=obj, *rv)
   File "C:\Python27\lib\pickle.py", line 419, in save_reduce
   save(state)
   File "C:\Python27\lib\pickle.py", line 286, in save if(self, obj) # Call unbound method with explicit self
   File "C:\Python27\lib\pickle.py", line 562, in save_tuple
   save(element)
   File "C:\Python27\lib\pickle.py", line 306, in save
    rv = reduce(self.proto)
   File "C:\Python27\lib\site-packages\billiard-2.7.3.10-py2.7-win32.egg\billiard\synchronize.py", line 122, in __getstate__
   sl.name)
   AttributeError: '_multiprocessing.SemLock' object has no attribute 'name'
   dispatch[key](self)
   File "C:\Python27\lib\pickle.py", line 880, in load_eof
   raise EOFError
   EOFError
   [2012-10-04 14:45:26,299: INFO/MainProcess] process shutting down

提前致谢

【问题讨论】:

【参考方案1】:

请升级到 celery 3.0.11,特别是最新的台球版本,因为这个 Windows 特定的错误最近已修复

【讨论】:

以上是关于django-celery 管理命令给出 AttributeError: '_multiprocessing.SemLock' 对象没有属性 'name'的主要内容,如果未能解决你的问题,请参考以下文章

如何修改django-celery web界面进行周期性调度

python3.7 中使用django-celery 完成异步任务

如何判断任务是不是已经在 django-celery 中排队?

Rails 的 ActiveRecord 序列化:attr 方法给出“缺少类或模块错误”

Django-celery 和 RabbitMQ 不执行任务

django-celery配置