From 55f98749e10b49999968b351cbadbe792860ec09 Mon Sep 17 00:00:00 2001 From: Goffi Date: Mon, 2 Nov 2015 22:02:41 +0100 Subject: [PATCH] plugin XEP-0085: fixed bad use of threads resulting in delay and crash when stopping the backend. --- src/plugins/plugin_xep_0085.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/plugins/plugin_xep_0085.py b/src/plugins/plugin_xep_0085.py index b7a60faf..0431fa02 100755 --- a/src/plugins/plugin_xep_0085.py +++ b/src/plugins/plugin_xep_0085.py @@ -29,8 +29,8 @@ try: 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 @@ class XEP_0085(object): 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 @@ class ChatStateMachine: 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):