TypeError: can't pickle memoryview objects when running basic add.delay(1,2) test
Posted
技术标签:
【中文标题】TypeError: can\'t pickle memoryview objects when running basic add.delay(1,2) test【英文标题】:TypeError: can't pickle memoryview objects when running basic add.delay(1,2) testTypeError: can't pickle memoryview objects when running basic add.delay(1,2) test 【发布时间】:2018-08-07 16:55:15 【问题描述】:尝试使用 celery 4.1.0 和 Python 3.6.4 运行 add.delay(1,2) 的最基本测试并得到以下错误:
[2018-02-27 13:58:50,194: INFO/MainProcess] 收到的任务: exb.tasks.test_tasks.add[52c3fb33-ce00-4165-ad18-15026eca55e9] [2018-02-27 13:58:50,194:CRITICAL/MainProcess] 不可恢复的错误: SystemError('返回一个带有错误集的结果',) Traceback (大多数 最近通话最后):文件 “/opt/myapp/lib/python3.6/site-packages/kombu/messaging.py”,第 624 行, 在 _receive_callback 返回 on_m(message) if on_m else self.receive(decoded, message) 文件 “/opt/myapp/lib/python3.6/site-packages/celery/worker/consumer/consumer.py”, 第 570 行,在 on_task_received 回调,文件“/opt/myapp/lib/python3.6/site-packages/celery/worker/strategy.py”, 第 145 行,在 task_message_handler 处理(请求)文件“/opt/myapp/lib/python3.6/site-packages/celery/worker/worker.py”,行 221,在_process_task_sem中 返回 self._quick_acquire(self._process_task, req) 文件“/opt/myapp/lib/python3.6/site-packages/kombu/async/semaphore.py”, 第 62 行,在获取中 回调(*partial_args,**partial_kwargs)文件“/opt/myapp/lib/python3.6/site-packages/celery/worker/worker.py”,行 226,在_process_task中 req.execute_using_pool(self.pool) 文件“/opt/myapp/lib/python3.6/site-packages/celery/worker/request.py”, 第 531 行,在 execute_using_pool 相关ID =任务ID,文件“/opt/myapp/lib/python3.6/site-packages/celery/concurrency/base.py”, 第 155 行,在 apply_async 中 **选项)文件“/opt/myapp/lib/python3.6/site-packages/billiard/pool.py”,第 1486 行, 在 apply_async self._quick_put((TASK, (result._job, None, func, args, kwds))) 文件 "/opt/myapp/lib/python3.6/site-packages/celery/concurrency/asynpool.py", 第 813 行,在 send_job 中 body = dumps(tup, protocol=protocol) TypeError: can't pickle memoryview objects
上述异常是以下异常的直接原因:
Traceback(最近一次调用最后一次):文件 “/opt/myapp/lib/python3.6/site-packages/celery/worker/worker.py”,行 203,在开始 self.blueprint.start(self) 文件“/opt/myapp/lib/python3.6/site-packages/celery/bootsteps.py”,行 119,开始 step.start(父)文件“/opt/myapp/lib/python3.6/site-packages/celery/bootsteps.py”,行 370,在开始 返回 self.obj.start() 文件“/opt/myapp/lib/python3.6/site-packages/celery/worker/consumer/consumer.py”, 第 320 行,开始 blueprint.start(self) 文件“/opt/myapp/lib/python3.6/site-packages/celery/bootsteps.py”,行 119,开始 step.start(父)文件“/opt/myapp/lib/python3.6/site-packages/celery/worker/consumer/consumer.py”, 第 596 行,开始 c.loop(*c.loop_args()) 文件“/opt/myapp/lib/python3.6/site-packages/celery/worker/loops.py”,行 88,在异步循环中 下一个(循环)文件“/opt/myapp/lib/python3.6/site-packages/kombu/async/hub.py”,第 354 行, 在 create_loop cb(*cbargs) 文件“/opt/myapp/lib/python3.6/site-packages/kombu/transport/base.py”,行 236,在 on_可读 阅读器(循环)文件“/opt/myapp/lib/python3.6/site-packages/kombu/transport/base.py”,行 218, 在 _read drain_events(timeout=0) 文件“/opt/myapp/lib/python3.6/site-packages/librabbitmq-2.0.0-py3.6-linux-x86_64.egg/librabbitmq/init。 py", 第 227 行,在 drain_events 中 self._basic_recv(timeout) SystemError: 返回一个带有错误集的结果
我找不到任何先前任何人遇到此错误的证据。我从 celery 网站注意到,仅提到支持 python 3.5,这是问题还是我缺少的东西?
任何帮助将不胜感激!
更新:尝试使用 Python 3.5.5 并且问题仍然存在。用 Django 4.0.2 试过,问题依然存在。
更新:卸载 librabbitmq 并且问题停止了。这是在从 Python 2.7.5、Django 1.7.7 迁移到 Python 3.6.4、Django 2.0.2 后看到的。
【问题讨论】:
我遇到了同样的问题 - @dparkeruk,你找到解决方案了吗? 【参考方案1】:卸载librabbitmq后,问题解决了。
【讨论】:
感谢@dparkeruk,但是您并没有使用性能更高的 librabbitmq,因为 amqp 正在下降,而是使用更慢的 pyamqp - docs.celeryproject.org/en/latest/userguide/… -- 对吗?希望你明白我的意思以上是关于TypeError: can't pickle memoryview objects when running basic add.delay(1,2) test的主要内容,如果未能解决你的问题,请参考以下文章
TypeError: can't pickle memoryview objects when running basic add.delay(1,2) test
TypeError: can't pickle generator objects: Spark collect() 由于不可序列化的生成器返回类型(dict_key)而失败
pickle.PicklingError: Can't pickle: it's not the same object as
pickle.PicklingError: Can't pickle <function past_match_sim at 0x7fa26e03b7b8>: attribute look
multiprocessing.Pool - PicklingError: Can't pickle <type 'thread.lock'>: 属性查找 thread.lock 失败
PicklingError: Can't pickle <class 'decimal.Decimal'>: it's not the same object as decimal.Dec