limscoder / amfast

An Adobe AMF serialization and RPC implementation for Python, written as a C extension for speed.
MIT License
5 stars 6 forks source link

Long-polling not works with multiple http server #84

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
Try to use Long-polling with multiple http server

Please provide any additional information below.
Because class Connection's static attr "_notifications" cannot be shared 
between different Python interpreter,the HttpChannel's "_notifyConnections" 
method cannot trigger the "notification event" in other interpreter.

Original issue reported on code.google.com by qihan...@gmail.com on 29 Jan 2012 at 9:00

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
The default ConnectionManager and SubscriptionManager classes store message 
data in local memory, so they won't work in a multi-server environment. 
Configure your messaging system with one of the alternate manager classes to 
work in a multi-server environment. I recommend the 
sa_connection_manager.SaConnectionManager and 
sa_subscription_manager.SaSubscriptionManager classes.

Original comment by dthomp...@rallydev.com on 30 Jan 2012 at 3:59

GoogleCodeExporter commented 9 years ago
thanks for comment~

I am using the memcache-connectionManager and memcache-subscriptionManager, 
because of a little worried about db's performance.

And,the long-polling seems doesnot work with gevent/tornado as http server.

event.wait() is still block,while a new message is ready in other 
coroutine/interpreter

I am using : nginx(upstreaming) + several gevent/tornado process(http server) + 
django/amfast(framework) + logical code

I saw the docstring in httpchannel._waitForMessage method,but I'm not sure 
whether the gevent is a Synchronous servers or not.

Original comment by qihan...@gmail.com on 1 Feb 2012 at 10:10

GoogleCodeExporter commented 9 years ago
env:nginx(upstreaming) + ONE gevent/tornado process(http server) + 
django/amfast(framework) + logical code

when I publish a msg,I got an error below:

File 
"/usr/local/lib/python2.6/dist-packages/AmFast-0.5.3_r536-py2.6-linux-i686.egg/a
mfast/remoting/thread_pool.py", line 64, in run
    task()
  File "/usr/local/lib/python2.6/dist-packages/AmFast-0.5.3_r536-py2.6-linux-i686.egg/amfast/remoting/thread_pool.py", line 12, in __call__
    self.function(*self.args, **self.kwargs)
  File "/usr/local/lib/python2.6/dist-packages/AmFast-0.5.3_r536-py2.6-linux-i686.egg/amfast/remoting/channel.py", line 438, in _notifyConnections
    if connection.notify_func is not None:
  File "/usr/local/lib/python2.6/dist-packages/AmFast-0.5.3_r536-py2.6-linux-i686.egg/amfast/remoting/connection.py", line 102, in _getNotifyFunc
    return self._manager.getNotifyFunc(self)
  File "/usr/local/lib/python2.6/dist-packages/AmFast-0.5.3_r536-py2.6-linux-i686.egg/amfast/remoting/memcache_connection_manager.py", line 158, in getNotifyFunc
    return connection._getNotifyFuncById(connection._notify_func_id)
AttributeError: 'Connection' object has no attribute '_notify_func_id'

I read the code in remoting/memcache_connection_manager.py:
    def getNotifyFunc(self, connection):
        notify_func_id = self.mc.get(self.getKeyName(connection.id, 'notify_func_id'))

        if notify_func_id is None:
            return None
        else:
            return connection._getNotifyFuncById(connection._notify_func_id)

I guess the last line should be:
return connection._getNotifyFuncById(notify_func_id)
instead of 
return connection._getNotifyFuncById(connection._notify_func_id)

Original comment by qihan...@gmail.com on 2 Feb 2012 at 8:18