我正在使用一个RabbitMQ队列来使用pika实现我的python tcp服务器。客户端对我的服务器的请求以no_ack方式从公共队列中消耗与该请求相关的消息。有时候,当并行运行更多客户端时,我会遇到异常。
异常的堆栈跟踪是:
result = channel.basic_get(queue=request_id, no_ack=False)
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 1935, in basic_get
self._basic_getempty_result.is_ready)
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 1174, in _flush_output
*waiters)
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 410, in _flush_output
self._impl.ioloop.poll()
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/select_connection.py", line 602, in poll
self._process_fd_events(fd_event_map, write_only)
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/select_connection.py", line 443, in _process_fd_events
handler(fileno, events, write_only=write_only)
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/base_connection.py", line 364, in _handle_events
self._handle_read()
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/base_connection.py", line 415, in _handle_read
self._on_data_available(data)
File "/usr/local/lib/python2.7/dist-packages/pika/connection.py", line 1347, in _on_data_available
self._process_frame(frame_value)
File "/usr/local/lib/python2.7/dist-packages/pika/connection.py", line 1414, in _process_frame
if self._process_callbacks(frame_value):
File "/usr/local/lib/python2.7/dist-packages/pika/connection.py", line 1384, in _process_callbacks
frame_value) # Args
File "/usr/local/lib/python2.7/dist-packages/pika/callback.py", line 60, in wrapper
return function(*tuple(args), **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pika/callback.py", line 92, in wrapper
return function(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pika/callback.py", line 236, in process
callback(*args, **keywords)
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 102, in set_value_once
self.signal_once()
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 93, in signal_once
assert not self._ready, '_CallbackResult was already set'