mirror of
https://github.com/django/daphne.git
synced 2024-11-22 07:56:34 +03:00
Merge pull request #47 from Krukov/fix-285-channels-issue
Catching error at receive_many form channel layer
This commit is contained in:
commit
6df13290b2
|
@ -94,14 +94,19 @@ class Server(object):
|
||||||
# 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:
|
||||||
delay = 0.01
|
delay = 0.01
|
||||||
channel, message = self.channel_layer.receive_many(channels, block=False)
|
try:
|
||||||
if channel:
|
channel, message = self.channel_layer.receive_many(channels, block=False)
|
||||||
delay = 0.00
|
except Exception as e:
|
||||||
# Deal with the message
|
logger.error('Error at trying to receive messages: %s' % e)
|
||||||
try:
|
delay = 5.00
|
||||||
self.factory.dispatch_reply(channel, message)
|
else:
|
||||||
except Exception as e:
|
if channel:
|
||||||
logger.error("HTTP/WS send decode error: %s" % e)
|
delay = 0.00
|
||||||
|
# Deal with the 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
|
||||||
|
@ -116,15 +121,20 @@ class Server(object):
|
||||||
return
|
return
|
||||||
channels = self.factory.reply_channels()
|
channels = self.factory.reply_channels()
|
||||||
if channels:
|
if channels:
|
||||||
channel, message = yield self.channel_layer.receive_many_twisted(channels)
|
try:
|
||||||
# Deal with the message
|
channel, message = yield self.channel_layer.receive_many_twisted(channels)
|
||||||
if channel:
|
except Exception as e:
|
||||||
try:
|
logger.error('Error at trying to receive messages: %s' % e)
|
||||||
self.factory.dispatch_reply(channel, message)
|
yield self.sleep(5.00)
|
||||||
except Exception as e:
|
|
||||||
logger.error("HTTP/WS send decode error: %s" % e)
|
|
||||||
else:
|
else:
|
||||||
yield self.sleep(0.01)
|
# Deal with the message
|
||||||
|
if channel:
|
||||||
|
try:
|
||||||
|
self.factory.dispatch_reply(channel, message)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error("HTTP/WS send decode error: %s" % e)
|
||||||
|
else:
|
||||||
|
yield self.sleep(0.01)
|
||||||
else:
|
else:
|
||||||
yield self.sleep(0.05)
|
yield self.sleep(0.05)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user