Skip to main content
 首页 » 编程设计

python celry + amazon EC2 由于散列而失败

2025年05月04日14hnrainll

我正在尝试在 Python 中使用 Amazon EC2。当我尝试从 celery 运行第一个样本时,它在本地使用 RabbitMQ 时工作正常,每当我依赖 EC2 时,我都会收到此消息: [2012-07-25 15:14:33,842: INFO/MainProcess] 从经纪人处获得任务:celery_test.add[2eed1b15-fda7-4036-be92-a7fd921f0f5d] [2012-07-25 15:14:33,881: WARNING/MainProcess] Task Handler ERROR: PicklingError("Can't pickle : attribute lookup _hashlib.HASH failed",)

我不太清楚它在哪个点/对象上未能 pickle 。

代码来自他们的示例:

@celery.task 
def add(x, y): 
   return x + y 

我这样调用它:add.delay(4, 4)

有什么我做错的提示吗?

谢谢!

请您参考如下方法:

您使用的是定制的 Python 吗?由于缺少 openssl-dev header ,hashlib 模块可能未正确构建。您可以在服务器上的 Python CLI 中手动运行 import hashlib 检查它。