芹菜错误:result.get(超时= 5)超时即使result.status是SUCCESS

问题描述 投票:2回答:1

我有开始通过result = task.delay()芹菜任务,然后等待通过result.get(timeout=5)结果的API。我目前正在写一个性能测试,这确实经常执行此任务。它工作正常,我的本地机器上,但是当我们发展的VM内执行的显示怪异的行为。经过约90-92处决,result.get(timeout=5)超时,即使工作几毫秒之内成功。

它几乎好像结果进去的结果后端失踪。我使用的RabbitMQ作为两个方向消息代理:

celery_broker_url = pyamqp://guest@localhost//
celery_result_backend = rpc://

谁能给我就如何进一步调查此问题的提示?是否有可能检查结果传递到结果后台?该RabbitMQ的日志不显示任何条目:

-- Logs begin at Wed 2019-01-30 16:49:24 UTC, end at Thu 2019-01-31 14:01:46 UTC. --
-- No entries --

下面是情况下,完整的堆栈跟踪它可以帮助:

[2019-01-31 13:56:42,313] ERROR in app: Exception on /user/lmhsqs/register [POST]

Traceback (most recent call last):

  File "/usr/local/lib/python3.6/dist-packages/celery/backends/async.py", line 255, in _wait_for_pending

    on_interval=on_interval):

  File "/usr/local/lib/python3.6/dist-packages/celery/backends/async.py", line 54, in drain_events_until

    raise socket.timeout()

socket.timeout



During handling of the above exception, another exception occurred:



Traceback (most recent call last):

  File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1982, in wsgi_app

    response = self.full_dispatch_request()

  File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1614, in full_dispatch_request

    rv = self.handle_user_exception(e)

  File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1517, in handle_user_exception

    reraise(exc_type, exc_value, tb)

  File "/usr/local/lib/python3.6/dist-packages/flask/_compat.py", line 33, in reraise

    raise value

  File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1612, in full_dispatch_request

    rv = self.dispatch_request()

  File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1598, in dispatch_request

    return self.view_functions[rule.endpoint](**req.view_args)

  File "/usr/local/lib/python3.6/dist-packages/connexion/decorators/decorator.py", line 66, in wrapper

    response = function(request)

  File "/usr/local/lib/python3.6/dist-packages/connexion/decorators/validation.py", line 122, in wrapper

    response = function(request)

  File "/usr/local/lib/python3.6/dist-packages/connexion/decorators/validation.py", line 293, in wrapper

    return function(request)

  File "/usr/local/lib/python3.6/dist-packages/connexion/decorators/decorator.py", line 42, in wrapper

    response = function(request)

  File "/usr/local/lib/python3.6/dist-packages/connexion/decorators/parameter.py", line 219, in wrapper

    return function(**kwargs)

  File "/mynedata/lib/api/apicalls.py", line 73, in register_user

    res_to_return = result.get(timeout=5)

  File "/usr/local/lib/python3.6/dist-packages/celery/result.py", line 224, in get

    on_message=on_message,

  File "/usr/local/lib/python3.6/dist-packages/celery/backends/async.py", line 188, in wait_for_pending

    for _ in self._wait_for_pending(result, **kwargs):

  File "/usr/local/lib/python3.6/dist-packages/celery/backends/async.py", line 259, in _wait_for_pending

    raise TimeoutError('The operation timed out.')

celery.exceptions.TimeoutError: The operation timed out.

127.0.0.1 - - [2019-01-31 13:56:42] "POST /user/lmhsqs/register HTTP/1.1" 500 388 5.050726

[2019-01-31 13:56:47,374] ERROR in app: Exception on /user/lmhsqs/login [POST]

Traceback (most recent call last):

  File "/usr/local/lib/python3.6/dist-packages/celery/backends/async.py", line 255, in _wait_for_pending

    on_interval=on_interval):

  File "/usr/local/lib/python3.6/dist-packages/celery/backends/async.py", line 54, in drain_events_until

    raise socket.timeout()

socket.timeout



During handling of the above exception, another exception occurred:



Traceback (most recent call last):

  File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1982, in wsgi_app

    response = self.full_dispatch_request()

  File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1614, in full_dispatch_request

    rv = self.handle_user_exception(e)

  File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1517, in handle_user_exception

    reraise(exc_type, exc_value, tb)

  File "/usr/local/lib/python3.6/dist-packages/flask/_compat.py", line 33, in reraise

    raise value

  File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1612, in full_dispatch_request

    rv = self.dispatch_request()

  File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1598, in dispatch_request

    return self.view_functions[rule.endpoint](**req.view_args)

  File "/usr/local/lib/python3.6/dist-packages/connexion/decorators/decorator.py", line 66, in wrapper

    response = function(request)

  File "/usr/local/lib/python3.6/dist-packages/connexion/decorators/validation.py", line 122, in wrapper

    response = function(request)

  File "/usr/local/lib/python3.6/dist-packages/connexion/decorators/validation.py", line 293, in wrapper

    return function(request)

  File "/usr/local/lib/python3.6/dist-packages/connexion/decorators/decorator.py", line 42, in wrapper

    response = function(request)

  File "/usr/local/lib/python3.6/dist-packages/connexion/decorators/parameter.py", line 219, in wrapper

    return function(**kwargs)

  File "/mynedata/lib/api/apicalls.py", line 123, in login_user

    res = result.get(timeout=5)

  File "/usr/local/lib/python3.6/dist-packages/celery/result.py", line 224, in get

    on_message=on_message,

  File "/usr/local/lib/python3.6/dist-packages/celery/backends/async.py", line 188, in wait_for_pending

    for _ in self._wait_for_pending(result, **kwargs):

  File "/usr/local/lib/python3.6/dist-packages/celery/backends/async.py", line 259, in _wait_for_pending

    raise TimeoutError('The operation timed out.')

celery.exceptions.TimeoutError: The operation timed out.
python-3.x rabbitmq celery
1个回答
0
投票

这个问题是不是与芹菜或RabbitMQ的,但完全无关:

我使用os.subprocess.Popen(shlex.split(backend_cmd), stdout=subprocess.PIPE, stderr=subprocess.STDOUT)开始芹菜工人。原来,subprocess.PIPE管将全面在某些时候(我觉得后2 ^ 16个字符),此时我的芹菜工人被困试图写管道,从而停笔结果结果后端。这意味着我看到的超时是有效的。

我不明白为什么result.status显示超时后“成功”虽然。

© www.soinside.com 2019 - 2024. All rights reserved.