1

当我尝试使用 celery 和 amqp 执行任务时出现以下错误,我的配置是否有问题。我该如何解决?

[2012-06-12 16:49:37,231: CRITICAL/MainProcess] Task core.tasks.sanity[c44c8058-46d1-48cd-a687-0481f5bd5ee5] INTERNAL ERROR: error("'i' format requires -2147483648 <= number <= 2147483647",)
Traceback (most recent call last):
  File "/nobackup/vivenara/pyenv/lib/python2.7/site-packages/celery/execute/trace.py", line 192, in trace_task
    R = I.handle_error_state(task, eager=eager)
  File "/nobackup/vivenara/pyenv/lib/python2.7/site-packages/celery/execute/trace.py", line 91, in handle_error_state
    }[self.state](task, store_errors=store_errors)
  File "/nobackup/vivenara/pyenv/lib/python2.7/site-packages/celery/execute/trace.py", line 114, in handle_failure
    task.backend.mark_as_failure(req.id, exc, self.strtb)
  File "/nobackup/vivenara/pyenv/lib/python2.7/site-packages/celery/backends/base.py", line 96, in mark_as_failure
    traceback=traceback)
  File "/nobackup/vivenara/pyenv/lib/python2.7/site-packages/celery/backends/base.py", line 229, in store_result
    return self._store_result(task_id, result, status, traceback, **kwargs)
  File "/nobackup/vivenara/pyenv/lib/python2.7/site-packages/celery/backends/amqp.py", line 121, in _store_result
    "traceback": traceback})
  File "/nobackup/vivenara/pyenv/lib/python2.7/site-packages/kombu/connection.py", line 272, in _ensured
    return fun(*args, **kwargs)
  File "/nobackup/vivenara/pyenv/lib/python2.7/site-packages/celery/backends/amqp.py", line 97, in _publish_result
    self._create_producer(task_id, connection).publish(meta)
  File "/nobackup/vivenara/pyenv/lib/python2.7/site-packages/celery/backends/amqp.py", line 87, in _create_producer
    self._create_binding(task_id)(connection.default_channel).declare()
  File "/nobackup/vivenara/pyenv/lib/python2.7/site-packages/kombu/entity.py", line 386, in declare
    self.queue_declare(nowait, passive=False)
  File "/nobackup/vivenara/pyenv/lib/python2.7/site-packages/kombu/entity.py", line 408, in queue_declare
    nowait=nowait)
  File "/nobackup/vivenara/pyenv/lib/python2.7/site-packages/amqplib/client_0_8/channel.py", line 1376, in queue_declare
    args.write_table(arguments)
  File "/nobackup/vivenara/pyenv/lib/python2.7/site-packages/amqplib/client_0_8/serialization.py", line 378, in write_table
    table_data.write(pack('>i', v))
error: 'i' format requires -2147483648 <= number <= 2147483647
4

1 回答 1

2

存储结果时值溢出:

error: 'i' format requires -2147483648 <= number <= 2147483647

一个 bigint/long 值被写入 AMQP 队列,而它识别为 int。我相信这不是配置问题。结果,您尝试保存的价值是多少?

我在堆栈跟踪中看到:

return self._store_result(task_id, result, status, traceback, **kwargs)

你能检查一下结果值是多少吗?可能这是一些奇怪的价值......

编辑

task.backend.mark_as_failure(req.id, exc, self.strtb)

所以在这种情况下,它返回 exc 作为结果:

def mark_as_failure(self, task_id, exc, traceback=None):
        """Mark task as executed with failure. Stores the execption."""
        return self.store_result(task_id, exc, status=states.FAILURE,
                                 traceback=traceback)

包含 bigint 状态代码的任务是否会引发异常?

于 2012-06-12T11:35:06.933 回答