Coder Social home page Coder Social logo

Comments (7)

kmike avatar kmike commented on August 17, 2024

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

from brukva.

kmike avatar kmike commented on August 17, 2024

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
[]

from brukva.

kmike avatar kmike commented on August 17, 2024

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.

from brukva.

evilkost avatar evilkost commented on August 17, 2024

Sorry, i can't reproduce. Could you try 85c67d9fe and show logs for additional info.

from brukva.

kmike avatar kmike commented on August 17, 2024

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

from brukva.

evilkost avatar evilkost commented on August 17, 2024

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?

from brukva.

burakdede avatar burakdede commented on August 17, 2024

[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()

from brukva.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.