From e918a860281675fc19c2c09bcf120c883ac7575f Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Thu, 10 May 2012 10:22:38 -0700 Subject: [PATCH] Make the error message better regarding hanged threads. All event handlers which call disconnect() MUST be registered using `add_event_handler(..., threaded=True)` in order to prevent temporarily deadlocking until a timeout occurs. This is required because disconnect() waits for the main threads to exit before returning, including the event processing thread. Since handlers registered without `threaded=True` run in the event processing thread, the disconnect() call will deadlock. --- sleekxmpp/xmlstream/xmlstream.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sleekxmpp/xmlstream/xmlstream.py b/sleekxmpp/xmlstream/xmlstream.py index 34c9773c..daa1af1a 100644 --- a/sleekxmpp/xmlstream/xmlstream.py +++ b/sleekxmpp/xmlstream/xmlstream.py @@ -1206,7 +1206,10 @@ class XMLStream(object): if self.__thread_count != 0: log.error("Hanged threads: %s" % threading.enumerate()) log.error("This may be due to calling disconnect() " + \ - "from a non-threaded event handler.") + "from a non-threaded event handler. Be " + \ + "sure that event handlers that call " + \ + "disconnect() are registered using: " + \ + "add_event_handler(..., threaded=True)") def process(self, **kwargs): """Initialize the XML streams and begin processing events.