Search code examples
pythonpikapython-pika

connection_workflow.AMQPConnectorStackTimeout from BlockingConnection


A pika BlockingConnection attempt failed (pika version 1.0.0). The exception shown in the application log - adapters.utils.connection_workflow.AMQPConnectorStackTimeout - doesn't appear to be any of the exceptions in pika.exceptions.

Isn't pika supposed to convert internal exceptions such as this into one of those in pika.exceptions before surfacing it to the caller?

If not, how should I go about enumerating all the possible exceptions pika could raise so that I can decide which the caller can handle and which it should not attempt to handle? (Essentially, the caller needs to decide whether to exit on a non-recoverable exception or try again if the condition is probably transient.)

Maybe I've misinterpreted the application log, which is as follows:

2019-04-26T11:33:29.880310567Z ERROR:pika.adapters.utils.connection_workflow:Timeout while setting up AMQP to '█.█.█.█'/(<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_STREAM: 1>, 6, '█.█.█.█', ('█.█.█.█', ████)); ssl=False
2019-04-26T11:33:29.880880966Z ERROR:pika.adapters.utils.connection_workflow:AMQPConnector - reporting failure: AMQPConnectorAMQPHandshakeError: AMQPConnectorStackTimeout("Timeout during AMQP handshake'█.█.█.█'/(<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_STREAM: 1>, 6, '█.█.█.█', ('█.█.█.█', █)); ssl=False",)
2019-04-26T11:33:29.881053365Z ERROR:pika.adapters.utils.connection_workflow:AMQP connection workflow failed: AMQPConnectionWorkflowFailed: 1 exceptions in all; last exception - AMQPConnectorAMQPHandshakeError: AMQPConnectorStackTimeout("Timeout during AMQP handshake'█.█.█.█'/(<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_STREAM: 1>, 6, '█.█.█.█', ('█.█.█.█', ████)); ssl=False",); first exception - None.
2019-04-26T11:33:29.881150165Z ERROR:pika.adapters.utils.connection_workflow:AMQPConnectionWorkflow - reporting failure: AMQPConnectionWorkflowFailed: 1 exceptions in all; last exception - AMQPConnectorAMQPHandshakeError: AMQPConnectorStackTimeout("Timeout during AMQP handshake'█.█.█.█'/(<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_STREAM: 1>, 6, '█.█.█.█', ('█.█.█.█', ████)); ssl=False",); first exception - None
2019-04-26T11:33:29.881503064Z ERROR:pika.adapters.blocking_connection:Connection workflow failed: AMQPConnectionWorkflowFailed: 1 exceptions in all; last exception - AMQPConnectorAMQPHandshakeError: AMQPConnectorStackTimeout("Timeout during AMQP handshake'█.█.█.█'/(<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_STREAM: 1>, 6, '█.█.█.█', ('█.█.█.█', ████)); ssl=False",); first exception - None
2019-04-26T11:33:29.882705661Z ERROR:pika.adapters.blocking_connection:Error in _create_connection().
2019-04-26T11:33:29.882720061Z Traceback (most recent call last):
2019-04-26T11:33:29.882724561Z   File "/usr/lib/python3.6/site-packages/pika/adapters/blocking_connection.py", line 451, in _create_connection
2019-04-26T11:33:29.882728961Z     raise self._reap_last_connection_workflow_error(error)
2019-04-26T11:33:29.882732761Z pika.adapters.utils.connection_workflow.AMQPConnectorStackTimeout: Timeout during AMQP handshake'█.█.█.█'/(<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_STREAM: 1>, 6, '█.█.█.█', ('█.█.█.█', ████)); ssl=False
2019-04-26T11:33:29.883257859Z ERROR:root:AMQPConnectorStackTimeout Timeout during AMQP handshake'█.█.█.█'/(<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_STREAM: 1>, 6, '█.█.█.█', ('█.█.█.█', ████)); ssl=False
2019-04-26T11:33:29.883273859Z Traceback (most recent call last):
2019-04-26T11:33:29.883278359Z   File "main.py", line 143, in <module>
2019-04-26T11:33:29.883282559Z     main()
2019-04-26T11:33:29.883286259Z   File "main.py", line 118, in main
2019-04-26T11:33:29.883290059Z     with pika.BlockingConnection(parameters=pika.URLParameters(██████████)) as connection:
2019-04-26T11:33:29.883293959Z   File "/usr/lib/python3.6/site-packages/pika/adapters/blocking_connection.py", line 360, in __init__
2019-04-26T11:33:29.883307559Z     self._impl = self._create_connection(parameters, _impl_class)
2019-04-26T11:33:29.883311659Z   File "/usr/lib/python3.6/site-packages/pika/adapters/blocking_connection.py", line 451, in _create_connection
2019-04-26T11:33:29.883315459Z     raise self._reap_last_connection_workflow_error(error)
2019-04-26T11:33:29.883319059Z pika.adapters.utils.connection_workflow.AMQPConnectorStackTimeout: Timeout during AMQP handshake'█.█.█.█'/(<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_STREAM: 1>, 6, '█.█.█.█', ('█.█.█.█', ████)); ssl=False
2019-04-26T11:33:29.883323159Z Traceback (most recent call last):
2019-04-26T11:33:29.883326759Z   File "main.py", line 143, in <module>
2019-04-26T11:33:29.883465559Z     main()
2019-04-26T11:33:29.883473059Z   File "main.py", line 118, in main
2019-04-26T11:33:29.883635558Z     with pika.BlockingConnection(parameters=pika.URLParameters(██████████)) as connection:
2019-04-26T11:33:29.883650458Z   File "/usr/lib/python3.6/site-packages/pika/adapters/blocking_connection.py", line 360, in __init__
2019-04-26T11:33:29.883894657Z     self._impl = self._create_connection(parameters, _impl_class)
2019-04-26T11:33:29.883902657Z   File "/usr/lib/python3.6/site-packages/pika/adapters/blocking_connection.py", line 451, in _create_connection
2019-04-26T11:33:29.884212657Z     raise self._reap_last_connection_workflow_error(error)
2019-04-26T11:33:29.884222357Z pika.adapters.utils.connection_workflow.AMQPConnectorStackTimeout: Timeout during AMQP handshake'█.█.█.█'/(<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_STREAM: 1>, 6, '█.█.█.█', ('█.█.█.█', ████)); ssl=False

Solution

  • I had this problem again and found my own question :-)

    The documentation seems a bit lacking, but there is a whole hierarchy of exceptions in pika.adapters.utils.connection_workflow, the base class of which is AMQPConnectorException.

    The answer seems to be to browse this module source to see which exceptions ought to be handled.