Closed DamCour closed 9 years ago
I'm working through a few related exceptions and will have it updated soon.
Here's what I've been testing with to get things cleanly raising catchable exceptions on disconnect:
import logging
import time
import rabbitpy
from rabbitpy import exceptions
logging.basicConfig(level=logging.DEBUG)
def run():
logging.info('Connecting')
try:
with rabbitpy.Connection() as connection:
with connection.channel() as channel:
queue = rabbitpy.Queue(channel, 'test')
queue.declare()
logging.info('Consuming')
for message in queue:
message.ack()
message.pprint(False)
except (exceptions.ConnectionResetException,
exceptions.AMQPConnectionForced) as error:
logging.error('Connection error: %s', error)
while True:
run()
logging.info('After run')
time.sleep(5)
Hello,
The fix seems to have solved my problem.
Thank you very much for that and for all the work you make on rabbitpy, I'm having a lot of fun playing with it.
Cheers,
Damien
Hi,
I've been trying to make rabbitpy restart consuming after a rabbitmq restart but there seem to be some problems:
A simple consumer:
After a rabbitmq server restart:
And the script hangs... It looks like it is blocked in the channel close process.
The first workaround I found was to catch AMQPConnectionForced (because it seems to be the exception that is raised in rabbitpy when rabbitmq server restarts) and to mark the channel as closed manually.
Actually, it works when the AMQPConnectionForced is raised, but sometimes it is not, so the script still hangs.
I'm not very good at python and thus I definitely could be wrong but I think io.py on_error function needs to be modified into something like this:
Am I right or am I doing things bad ?
Thank you in advance for your responses.
Cheers,
Damien