mirror of
https://github.com/django/daphne.git
synced 2024-11-22 07:56:34 +03:00
Allow signal handlers to be disabled to run in subthread
This commit is contained in:
parent
95ef5c96e2
commit
8c1b7f8a5a
|
@ -6,16 +6,17 @@ from .http_protocol import HTTPFactory
|
||||||
|
|
||||||
class Server(object):
|
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.channel_layer = channel_layer
|
||||||
self.host = host
|
self.host = host
|
||||||
self.port = port
|
self.port = port
|
||||||
|
self.signal_handlers = signal_handlers
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.factory = HTTPFactory(self.channel_layer)
|
self.factory = HTTPFactory(self.channel_layer)
|
||||||
reactor.listenTCP(self.port, self.factory, interface=self.host)
|
reactor.listenTCP(self.port, self.factory, interface=self.host)
|
||||||
reactor.callInThread(self.backend_reader)
|
reactor.callInThread(self.backend_reader)
|
||||||
reactor.run()
|
reactor.run(installSignalHandlers=self.signal_handlers)
|
||||||
|
|
||||||
def backend_reader(self):
|
def backend_reader(self):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user