mirror of
https://github.com/django/daphne.git
synced 2025-07-10 16:02:18 +03:00
Correctly catch send dispatch errors
This commit is contained in:
parent
c71a035004
commit
fca52d4850
|
@ -66,11 +66,11 @@ class Server(object):
|
||||||
else:
|
else:
|
||||||
reactor.listenTCP(self.port, self.factory, interface=self.host)
|
reactor.listenTCP(self.port, self.factory, interface=self.host)
|
||||||
|
|
||||||
if "twisted" in self.channel_layer.extensions:
|
if "twisted" in self.channel_layer.extensions and False:
|
||||||
logging.info("Using native Twisted mode on channel layer")
|
logger.info("Using native Twisted mode on channel layer")
|
||||||
reactor.callLater(0, self.backend_reader_twisted)
|
reactor.callLater(0, self.backend_reader_twisted)
|
||||||
else:
|
else:
|
||||||
logging.info("Using busy-loop synchronous mode on channel layer")
|
logger.info("Using busy-loop synchronous mode on channel layer")
|
||||||
reactor.callLater(0, self.backend_reader_sync)
|
reactor.callLater(0, self.backend_reader_sync)
|
||||||
reactor.callLater(2, self.timeout_checker)
|
reactor.callLater(2, self.timeout_checker)
|
||||||
reactor.run(installSignalHandlers=self.signal_handlers)
|
reactor.run(installSignalHandlers=self.signal_handlers)
|
||||||
|
@ -84,7 +84,7 @@ class Server(object):
|
||||||
delay = 0.05
|
delay = 0.05
|
||||||
# Quit if reactor is stopping
|
# Quit if reactor is stopping
|
||||||
if not reactor.running:
|
if not reactor.running:
|
||||||
logging.debug("Backend reader quitting due to reactor stop")
|
logger.debug("Backend reader quitting due to reactor stop")
|
||||||
return
|
return
|
||||||
# Don't do anything if there's no channels to listen on
|
# Don't do anything if there's no channels to listen on
|
||||||
if channels:
|
if channels:
|
||||||
|
@ -93,7 +93,10 @@ class Server(object):
|
||||||
if channel:
|
if channel:
|
||||||
delay = 0.00
|
delay = 0.00
|
||||||
# Deal with the message
|
# Deal with the message
|
||||||
self.factory.dispatch_reply(channel, message)
|
try:
|
||||||
|
self.factory.dispatch_reply(channel, message)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error("HTTP/WS send decode error: %s" % e)
|
||||||
reactor.callLater(delay, self.backend_reader_sync)
|
reactor.callLater(delay, self.backend_reader_sync)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
|
@ -111,7 +114,10 @@ class Server(object):
|
||||||
channel, message = yield self.channel_layer.receive_many_twisted(channels)
|
channel, message = yield self.channel_layer.receive_many_twisted(channels)
|
||||||
# Deal with the message
|
# Deal with the message
|
||||||
if channel:
|
if channel:
|
||||||
self.factory.dispatch_reply(channel, message)
|
try:
|
||||||
|
self.factory.dispatch_reply(channel, message)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error("HTTP/WS send decode error: %s" % e)
|
||||||
else:
|
else:
|
||||||
yield self.sleep(0.01)
|
yield self.sleep(0.01)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user