ValueError:不支持的哈希类型md5

时间:2016-05-24 08:56:34

标签: python celery hashlib

我写了一个python c扩展来实现PEP302来定义我自己的meta_path钩子和路径钩子,这样我就可以加载加密python模块

// c扩展代码http://pastie.org/private/c2tslasqg6omph2i88oug

我修改了site.py(python -c“import site; print site .__ file__”),附加两行:

sys.path.append('/opt/pycode-encrypt')
import hacksite

// hacksite code http://pastie.org/private/epfsnfgz7fwhdwavtqxvw

现在的问题是: 当我使用原始代码启动芹菜工人时,一切都很好 但当我用我的扩展加密代码,然后我用--autoreload启动芹菜工作者,我有一些错误:

[2016-05-24 16:01:20,709: ERROR/MainProcess] Unrecoverable error: ValueError('unsupported hash type md5',)
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/celery-3.1.18-py2.7.egg/celery/worker/__init__.py", line 206, in start
    self.blueprint.start(self)
  File "/usr/local/lib/python2.7/dist-packages/celery-3.1.18-py2.7.egg/celery/bootsteps.py", line 123, in start
    step.start(parent)
  File "/usr/local/lib/python2.7/dist-packages/celery-3.1.18-py2.7.egg/celery/bootsteps.py", line 374, in start
    return self.obj.start()
  File "/usr/local/lib/python2.7/dist-packages/celery-3.1.18-py2.7.egg/celery/worker/consumer.py", line 278, in start
    blueprint.start(self)
  File "/usr/local/lib/python2.7/dist-packages/celery-3.1.18-py2.7.egg/celery/bootsteps.py", line 123, in start
    step.start(parent)
  File "/usr/local/lib/python2.7/dist-packages/celery-3.1.18-py2.7.egg/celery/worker/consumer.py", line 821, in start
    c.loop(*c.loop_args())
  File "/usr/local/lib/python2.7/dist-packages/celery-3.1.18-py2.7.egg/celery/worker/loops.py", line 41, in asynloop
    obj.controller.register_with_event_loop(hub)
  File "/usr/local/lib/python2.7/dist-packages/celery-3.1.18-py2.7.egg/celery/worker/__init__.py", line 218, in register_with_event_loop
    description='hub.register',
  File "/usr/local/lib/python2.7/dist-packages/celery-3.1.18-py2.7.egg/celery/bootsteps.py", line 155, in send_all
    fun(parent, *args)
  File "/usr/local/lib/python2.7/dist-packages/celery-3.1.18-py2.7.egg/celery/worker/autoreload.py", line 60, in register_with_event_loop
    w.autoreloader.register_with_event_loop(hub)
  File "/usr/local/lib/python2.7/dist-packages/celery-3.1.18-py2.7.egg/celery/worker/autoreload.py", line 286, in register_with_event_loop
    self.on_init()
  File "/usr/local/lib/python2.7/dist-packages/celery-3.1.18-py2.7.egg/celery/worker/autoreload.py", line 282, in on_init
    self._hashes = dict([(f, file_hash(f)) for f in files])
  File "/usr/local/lib/python2.7/dist-packages/celery-3.1.18-py2.7.egg/celery/worker/autoreload.py", line 81, in file_hash
    hobj = hashlib.new(algorithm)
  File "/usr/lib/python2.7/hashlib.py", line 128, in __hash_new
    return __get_builtin_constructor(name)(string)
  File "/usr/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type %s' % name)
ValueError: unsupported hash type md5

但在python交互模式下,我可以导入_hashlib,我可以无误地运行_hashlib.new('md5','msg')。
错误恰好发生在芹菜工人身上--autoreload params

我也做了一些测试,我发现:
我修改/ usr / bin / celery添加一些测试代码尝试使用_hashlib.new并且没问题。 但是celery/worker/autoreload.py#file_hash中的相同代码会引发ValueError。

我是python c扩展开发的新手,我为这个问题工作了一段时间,我找不到一些有用的东西来解决这个问题。

所以我来这里寻求帮助。

谢谢

0 个答案:

没有答案