使用shared_task和queue选项的Python3异常

时间:2018-09-28 14:03:41

标签: python-3.x python-2.7 celery

我正在尝试迁移到python3(3.6),并且从芹菜中遇到TypeError: an integer is required (got type NoneType)的问题,它引发了from celery import shared_task QUEUE = 'ukrdc_importer' @shared_task(queue=QUEUE) def import_data(num1, num2): return num1 + num2 @api.route('/import', methods=['POST']) def import_(): res = import_data.delay(1, 1) return Response(status=200) 。我设法将问题缩小到shared_task装饰器中的队列参数。这就是我所拥有的:

queue

这是来自烧瓶应用程序。它在python2中工作得很好,如果我从shared_task调用中删除了127.0.0.1 - - [28/Sep/2018 14:17:11] "POST /import HTTP/1.1" 500 - Traceback (most recent call last): File "/home/rapolas/projects/radar/venv/lib/python3.6/site-packages/flask/app.py", line 2309, in __call__ return self.wsgi_app(environ, start_response) File "/home/rapolas/projects/radar/venv/lib/python3.6/site-packages/flask/app.py", line 2295, in wsgi_app response = self.handle_exception(e) File "/home/rapolas/projects/radar/venv/lib/python3.6/site-packages/flask/app.py", line 1741, in handle_exception reraise(exc_type, exc_value, tb) File "/home/rapolas/projects/radar/venv/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise raise value File "/home/rapolas/projects/radar/venv/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app response = self.full_dispatch_request() File "/home/rapolas/projects/radar/venv/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request rv = self.handle_user_exception(e) File "/home/rapolas/projects/radar/venv/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception reraise(exc_type, exc_value, tb) File "/home/rapolas/projects/radar/venv/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise raise value File "/home/rapolas/projects/radar/venv/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request rv = self.dispatch_request() File "/home/rapolas/projects/radar/venv/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/home/rapolas/projects/radar/radar/data_importer/api.py", line 24, in import_ res = import_sda1.delay(1, 1) File "/home/rapolas/projects/radar/venv/lib/python3.6/site-packages/celery/app/task.py", line 408, in delay return self.apply_async(args, kwargs) File "/home/rapolas/projects/radar/venv/lib/python3.6/site-packages/celery/app/task.py", line 535, in apply_async **options File "/home/rapolas/projects/radar/venv/lib/python3.6/site-packages/celery/app/base.py", line 744, in send_task amqp.send_task_message(P, name, message, **options) File "/home/rapolas/projects/radar/venv/lib/python3.6/site-packages/celery/app/amqp.py", line 552, in send_task_message **properties File "/home/rapolas/projects/radar/venv/lib/python3.6/site-packages/kombu/messaging.py", line 181, in publish exchange_name, declare, File "/home/rapolas/projects/radar/venv/lib/python3.6/site-packages/kombu/connection.py", line 494, in _ensured return fun(*args, **kwargs) File "/home/rapolas/projects/radar/venv/lib/python3.6/site-packages/kombu/messaging.py", line 203, in _publish mandatory=mandatory, immediate=immediate, File "/home/rapolas/projects/radar/venv/lib/python3.6/site-packages/librabbitmq/__init__.py", line 122, in basic_publish mandatory or False, immediate or False, TypeError: an integer is required (got type NoneType) 参数,它也可以工作,但是一旦添加,python3开始抛出所提到的异常,我不知道为什么... python2和3中的库版本相同。

已附加完整例外:

Person

0 个答案:

没有答案