Browse Source

add facility to shutdown client from external thread

master
Adam Gibson 9 years ago
parent
commit
d809038869
No known key found for this signature in database
GPG Key ID: B3AE09F1E9A3197A
  1. 11
      jmclient/client_protocol.py

11
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.

Loading…
Cancel
Save