Mercurial > libervia-backend
changeset 1547:0632d96f08ad
plugin XEP-0085: fixed bad use of threads resulting in delay and crash when stopping the backend.
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 02 Nov 2015 22:02:41 +0100 |
parents | 62d6310e7c04 |
children | 61c03265e133 |
files | src/plugins/plugin_xep_0085.py |
diffstat | 1 files changed, 3 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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):