Yes, sure: #!/usr/bin/env python3
from proton.reactor import Container from proton.handlers import MessagingHandler from proton import Message, Connection import threading import sys class AmqpReceiver(MessagingHandler): def __init__(self): super().__init__(prefetch=50) self.host = "localhost:9001" self.container = Container(self) self.conn = None self.receiver = None self.thread = threading.Thread(target=self.run) self.thread.daemon = True self.thread.start() def on_message(self, event): print("got message: event: ", event.message) def on_start(self, event): print("on start") self.conn = self.container.connect(self.host, reconnect=False) self.receiver = self.container.create_receiver(self.conn, "test.awe.queue") def run(self): print("run container") self.container.run() print("after container.run()") sys.stdout.flush() def _stop(self): print('call stop') self.container.stop() print('call join') self.thread.join() print('done stop') def on_connection_closed(self, event): print("on_connection_closed") def on_session_closed(self, event): print("on_session_closed") def on_link_closed(self, event): print("on_link_closed") def on_disconnected(self, event): print("on_disconnected") try: handler = AmqpReceiver() input("press enter") handler._stop() except Exception as ex: print("got EXCEPTION") print(ex) On Thu, Feb 22, 2018 at 9:32 AM, Gordon Sim <g...@redhat.com> wrote: > On 22/02/18 08:05, andi welchlin wrote: > >> Hello all, >> >> I tried to stop the Proton MessagingHandler by calling >> self.container.stop() but this causes an endless loop (cpu goes to 100%). >> >> So I just could help myself to throw an exception. But I think this is not >> a good solution. >> >> Can someone tell me, how I can leave container.run() gracefully? >> > > If all connections it is managing are closed and there are no timed events > pending, it should exit by itself. > > Do you have an example you can share showing the problem? > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@qpid.apache.org > For additional commands, e-mail: users-h...@qpid.apache.org > >