Blocking connection can be recovered in exception handling style (similar to php client). For example:
while True:
connection = pika.BlockingConnection(parameters)
channel = connection.channel()
channel.basic_consume(on_message, 'queue')
try:
channel.start_consuming()
except pika.exceptions.ConnectionClosed:
LOGGER.info('Connection closed. Recovering')
continue
except KeyboardInterrupt:
channel.stop_consuming()
connection.close()
break
```
Created
May 7, 2020 07:10
-
-
Save Barolina/df97aee8a4d506dbaa481df7935166b7 to your computer and use it in GitHub Desktop.
pythin and pika and recovery (while)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment