我随机出现以下错误(即大多数情况下脚本工作正常)
File ".../backend/case_status_consumer.py", line 28, in <module>
channel.start_consuming()
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 955, in start_consuming
self.connection.process_data_events()
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 240, in process_data_events
if self._handle_read():
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 348, in _handle_read
super(BlockingConnection, self)._handle_read()
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/base_connection.py", line 351, in _handle_read
self._on_data_available(data)
File "/usr/local/lib/python2.7/dist-packages/pika/connection.py", line 1285, in _on_data_available
self._process_frame(frame_value)
File "/usr/local/lib/python2.7/dist-packages/pika/connection.py", line 1365, in _process_frame
self._deliver_frame_to_channel(frame_value)
File "/usr/local/lib/python2.7/dist-packages/pika/connection.py", line 976, in _deliver_frame_to_channel
return self._channels[value.channel_number]._handle_content_frame(value)
File "/usr/local/lib/python2.7/dist-packages/pika/channel.py", line 792, in _handle_content_frame
self._on_deliver(*response)
File "/usr/local/lib/python2.7/dist-packages/pika/channel.py", line 886, in _on_deliver
body)
File ".../backend/case_status_consumer.py", line 14, in consume_case_status
case_num['case_year'])
File ".../backend/src/fetcher/case_update.py", line 132, in case_update
properties=pika.BasicProperties(delivery_mode=2))
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 572, in basic_publish
(properties, body), False)
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 1159, in _send_method
self.connection.send_method(self.channel_number, method_frame, content)
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 274, in send_method
self._send_method(channel_number, method_frame, content)
File "/usr/local/lib/python2.7/dist-packages/pika/connection.py", line 1503, in _send_method
self._send_frame(frame.Method(channel_number, method_frame))
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 417, in _send_frame
super(BlockingConnection, self)._send_frame(frame_value)
File "/usr/local/lib/python2.7/dist-packages/pika/connection.py", line 1490, in _send_frame
self._flush_outbound()
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 377, in _flush_outbound
if self._handle_write():
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/base_connection.py", line 365, in _handle_write
return self._handle_error(error)
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/base_connection.py", line 302, in _handle_error
self._handle_disconnect()
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/base_connection.py", line 248, in _handle_disconnect
self._adapter_disconnect()
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 318, in _adapter_disconnect
self._check_state_on_disconnect()
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 371, in _check_state_on_disconnect
raise exceptions.ConnectionClosed()
pika.exceptions.ConnectionClosed
在制作过程中我也遇到了类似的错误。
File ".../backend/check_for_orders.py", line 115, in <module>
dated=order_dated, ors_fetch=False)
File ".../backend/src/fetcher/case_update.py", line 132, in case_update
properties=pika.BasicProperties(delivery_mode=2))
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 572, in basic_publish
(properties, body), False)
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 1159, in _send_method
self.connection.send_method(self.channel_number, method_frame, content)
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 274, in send_method
self._send_method(channel_number, method_frame, content)
File "/usr/local/lib/python2.7/dist-packages/pika/connection.py", line 1503, in _send_method
self._send_frame(frame.Method(channel_number, method_frame))
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 417, in _send_frame
super(BlockingConnection, self)._send_frame(frame_value)
File "/usr/local/lib/python2.7/dist-packages/pika/connection.py", line 1490, in _send_frame
self._flush_outbound()
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 377, in _flush_outbound
if self._handle_write():
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/base_connection.py", line 365, in _handle_write
return self._handle_error(error)
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/base_connection.py", line 302, in _handle_error
self._handle_disconnect()
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/base_connection.py", line 248, in _handle_disconnect
self._adapter_disconnect()
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 318, in _adapter_disconnect
self._check_state_on_disconnect()
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 371, in _check_state_on_disconnect
raise exceptions.ConnectionClosed()
pika.exceptions.ConnectionClosed
我的连接设置为:
connection = pika.BlockingConnection(pika.ConnectionParameters('localhost', heartbeat_interval=0))
我甚至尝试将心跳间隔设置为更长的时间(例如60和90),但我仍然会遇到这些错误。
我无法发布完整代码,但我的脚本正在做的是,使用'requests'来获取页面(超时为50秒,最多4次重试)
答案 0 :(得分:0)
此问题已在pika 0.10.0
中修复