diff --git a/jmclient/client_protocol.py b/jmclient/client_protocol.py index 4e7b004..f70d93d 100644 --- a/jmclient/client_protocol.py +++ b/jmclient/client_protocol.py @@ -2,6 +2,7 @@ from __future__ import print_function from twisted.python.log import startLogging, err from twisted.internet import protocol, reactor +from twisted.internet.task import LoopingCall from twisted.protocols import amp from twisted.internet.protocol import ClientFactory from twisted.internet.endpoints import TCP4ClientEndpoint @@ -39,6 +40,16 @@ class JMTakerClientProtocol(amp.AMP): else: self.nick_priv = nick_priv + self.shutdown_requested = False + lc = LoopingCall(self.checkForShutdown) + lc.start(0.2) + + def checkForShutdown(self): + if self.shutdown_requested: + jlog.info("Client shutdown was requested, complying.") + self.shutdown_requested = False + reactor.stop() + def checkClientResponse(self, response): """A generic check of client acceptance; any failure is considered criticial.