Open kmike opened 13 years ago
Hmm, this may be because I don't unsubscribe before disconnecting.
The bad thing is that exception occurred in Client.listen callback was printed to stderr and ignored so I haven't noticed it immediately:
Exception AttributeError: "'NoneType' object has no attribute 'channel'" in <generator object listen at 0x102a70aa0> ignored
I'm still getting None as a message sometimes (with latest master):
/Users/kmike/svn/tornadio/tornadio/server.py(71)__init__()
67 except Exception, ex:
68 logging.error('Failed to start Flash policy server: %s', ex)
69
70 logging.info('Entering IOLoop...')
---> 71 io_loop.start()
/Users/kmike/svn/tornado/tornado/ioloop.py(220)start()
218 callbacks = self._callbacks
219 self._callbacks = []
--> 220 for callback in callbacks:
221 self._run_callback(callback)
222
/Users/kmike/svn/brukva/brukva/client.py(914)listen()
912 break
913 else:
--> 914 ctx.ret_call(result)
915
916 ### CAS
/Users/kmike/svn/brukva/brukva/client.py(43)__exit__()
41
42 if self.is_active:
---> 43 self.ret_call(value)
44 return True
45 else:
/Users/kmike/svn/brukva/brukva/client.py(56)ret_call()
54 def ret_call(self, value):
55 self.is_active = False
---> 56 self._call_callbacks(self.callbacks, value)
57 self.is_active = True
58
/Users/kmike/svn/brukva/brukva/client.py(30)_call_callbacks()
28 cb(value)
29 else:
---> 30 callbacks(value)
31
32 def __enter__(self):
> /Users/kmike/dev/planor/realtime/connection.py(84)on_pubsub_message()
82 if message is None:
83 import ipdb; ipdb.set_trace()
---> 84 logging.warning('on_pubsub_message is None')
85 return
86
Don't know if it is a bug: pub/sub seems to work otherwise. Can you share some knowledge about what the problem may be?
State (maybe it will help):
ipdb> self.pubsub_client.subscribed
True
ipdb> self.pubsub_client._waiting_callbacks
defaultdict(<type 'list'>, {})
ipdb> self.pubsub_client.queue
[]
Btw,
self.is_active = False
self._call_callbacks(self.callbacks, value)
self.is_active = True
always seems scary (as well as ExecutionContext.enable and ExecutionContext.disable) because is_active can become incorrect if exception in _call_callbacks occurs and it is not clear how this is handled. Though I've checked the code when 'enable' and 'disable' methods were introduced and they were applied carefully, with all edge cases handled.
Sorry, i can't reproduce. Could you try 85c67d9fe and show logs for additional info.
Yes, sure. Thanks for moving things forward! It now produces this:
ERROR:brukva.client:None
Traceback (most recent call last):
File "/Users/kmike/svn/brukva/brukva/client.py", line 901, in listen
data = yield async(self.connection.readline)()
GeneratorExit
I'm confused by (type_=GeneratorExit, value==None) in ExecutionContext.exit . And why None is not replaced with Exception?!:
if self.error_wrapper:
value = self.error_wrapper(value)
else:
value = value or Exception(
'Strange exception with None value type: %s; tb: %s' %
(type_, '\n'.join(traceback.format_tb(tb))
))
Can't come up with test case to reproduce this. Could you extract example from your project?
[E 111211 10:54:35 client:49] None Traceback (most recent call last): File "/usr/local/lib/python2.6/dist-packages/brukva-0.0.1-py2.6.egg/brukva/client.py", line 926, in listen data = yield async(self.connection.readline)() GeneratorExit
Seems like this issue still holds. Here is scenerio for to reproduce it. Make a long polling for a while but if cilent move to idle state brukva fire this exception.
class MessageUpdatesHandler(BaseHandler):
@tornado.web.authenticated
@tornado.web.asynchronous
def post(self):
self.listing_id = self.get_argument("listing_id", None)
self.client = brukva.Client()
self.client.connect()
self.client.subscribe(self.listing_id)
self.client.listen(self.on_new_messages)
def on_new_messages(self, messages):
# Closed client connection
if self.request.connection.stream.closed():
return
self.finish(dict(messages=str(messages.body)))
self.client.unsubscribe(self.listing_id)
def on_connection_close(self):
# unsubscribe user from channel
self.client.unsubscribe(self.listing_id)
self.client.disconnect()
I got this problem again.
Stack trace from ipdb's 'bt' command: