fritzy / SleekXMPP

Python 2.6+/3.1+ XMPP Library
http://groups.google.com/group/sleekxmpp-discussion
Other
1.1k stars 299 forks source link

Unable to disconnect after sending MUC message (was: Disconnect(wait=True) crashes after sending MUC message) #141

Closed bond closed 12 years ago

bond commented 12 years ago

I've created a script based on the MUC bot example. After sending a MUC message, I call "disconnect(wait=True)" directly after it. It consistently crashes every time.

How to reproduce: run the Echo bot, but call "disconnect(wait=True)" directly after "muc_message" function calls "self.send_message()".

Debug output:

DEBUG MUC presence from utviklere@conference.chat.copyleft.no/db@chat.copyleft.no : {'status': '', 'nick': u'db@chat.copyleft.no', 'jid': , 'room': u'utviklere@conference.chat.copyleft.no', 'show': '', 'affiliation': 'none', 'role': 'participant'} DEBUG MUC presence from utviklere@conference.chat.copyleft.no/Lidless : {'status': '', 'nick': u'Lidless', 'jid': , 'room': u'utviklere@conference.chat.copyleft.no', 'show': '', 'affiliation': 'none', 'role': 'participant'} DEBUG SEND (IMMED): /stream:stream DEBUG Waiting for /stream:stream from server DEBUG End of stream recieved DEBUG Could not acquire lock Done Exception in thread stream_event_handler_0 (most likely raised during interpreter shutdown): Traceback (most recent call last): File "/usr/lib/python2.6/threading.py", line 532, in __bootstrap_inner File "/usr/lib/python2.6/threading.py", line 484, in run

Version: SleekXMPP 1.0rc3 running on Python 2.6.

Would just like to add that SleekXMPP is very nice, and thanks for the great effort put into it! :-)

legastero commented 12 years ago

That is an artifact of SleekXMPP using daemonized threads before the 1.0 release, and should be fixed now.

Daemonized threads which use objects from the global namespace (like imported modules) may cause exceptions as the program is shutting down because memory references are being cleared out.

bond commented 12 years ago

Thats, great. Thanks! :-)

bond commented 12 years ago

Hi, I can confirm that 1.0 does not have the issue with Crashing, like 1.0RC3 had. But now I have another (possibly related) problem.

I see in the debug output that "waiters" are depreciated, so I removed the "wait=True" on the send_message() and disconnect(), functions.

However, now it disconnects before the message reaches the MUC. I get no errors, and it shuts down cleanly.

Perhaps I'm doing the wrong thing by calling disconnect() ?

legastero commented 12 years ago

The wait=True for disconnect() is not deprecated, and is required to delay the disconnection until the send queue has emptied. Its purpose is to prevent the very situation you've described.

Where are you removing wait=True from a send_message() call, since that method does not take a wait parameter?

The depecration notices you saw are related to the use of XML masks, which the MUC plugin still uses for now, so just ignore those.

bond commented 12 years ago

It's working great now, thanks :-)