# HG changeset patch # User Goffi # Date 1446498161 -3600 # Node ID 0632d96f08ad839bc60716d50a11a5cda53c6722 # Parent 62d6310e7c04915d79f41eaec68548e4114f7857 plugin XEP-0085: fixed bad use of threads resulting in delay and crash when stopping the backend. diff -r 62d6310e7c04 -r 0632d96f08ad src/plugins/plugin_xep_0085.py --- a/src/plugins/plugin_xep_0085.py Mon Nov 02 22:02:41 2015 +0100 +++ b/src/plugins/plugin_xep_0085.py Mon Nov 02 22:02:41 2015 +0100 @@ -29,8 +29,8 @@ from twisted.words.protocols.xmlstream import XMPPHandler except ImportError: from wokkel.subprotocols import XMPPHandler -from threading import Timer from twisted.words.xish import domish +from twisted.internet import reactor NS_XMPP_CLIENT = "jabber:client" NS_CHAT_STATES = "http://jabber.org/protocol/chatstates" @@ -324,7 +324,7 @@ pass -class ChatStateMachine: +class ChatStateMachine(object): """ This class represents a chat state, between one profile and one target contact. A timer is used to move from one state @@ -372,12 +372,9 @@ client.xmlstream.send(mess_data['xml']) self.state = state - if self.timer is not None: - self.timer.cancel() if transition["next_state"] and transition["delay"] > 0: - self.timer = Timer(transition["delay"], self._onEvent, [transition["next_state"]]) - self.timer.start() + self.timer = reactor.callLater(transition["delay"], self._onEvent, transition["next_state"]) class XEP_0085_handler(XMPPHandler):