Allow signal handlers to be disabled to run in subthread

This commit is contained in:
Andrew Godwin 2016-02-10 19:23:52 +00:00
parent 95ef5c96e2
commit 8c1b7f8a5a

View File

@ -6,16 +6,17 @@ from .http_protocol import HTTPFactory
class Server(object):
def __init__(self, channel_layer, host="127.0.0.1", port=8000):
def __init__(self, channel_layer, host="127.0.0.1", port=8000, signal_handlers=True):
self.channel_layer = channel_layer
self.host = host
self.port = port
self.signal_handlers = signal_handlers
def run(self):
self.factory = HTTPFactory(self.channel_layer)
reactor.listenTCP(self.port, self.factory, interface=self.host)
reactor.callInThread(self.backend_reader)
reactor.run()
reactor.run(installSignalHandlers=self.signal_handlers)
def backend_reader(self):
"""