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

memcache_connection_manager.py", line 129, in iterConnectionIds 'NoneType' object has no attribute '__iter__' #66

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Full message Text:

Django version 1.2 beta 1 SVN-12990, using settings 'labCloud.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Exception in thread Thread-2:
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/threading.py", line 525, in __bootstrap_inner
    self.run()
  File "build/bdist.macosx-10.6-i386/egg/amfast/remoting/thread_pool.py", line 32, in run
    self.task()
  File "build/bdist.macosx-10.6-i386/egg/amfast/remoting/channel.py", line 337, in clean
    for connection_id in self.connection_manager.iterConnectionIds():
  File "build/bdist.macosx-10.6-i386/egg/amfast/remoting/memcache_connection_manager.py", line 129, in iterConnectionIds
    return connection_ids.__iter__()
AttributeError: 'NoneType' object has no attribute '__iter__'

When the server is started and there are no connections, this error is thrown 
when the clean process kicks off.  Need to check if connection_ids is null 
before returning iteration.

Original issue reported on code.google.com by cp...@wingsnwakes.com on 27 Jul 2010 at 3:01

GoogleCodeExporter commented 9 years ago
Here's a DIFF of how I fixed the issue.  There might be a more efficient or 
"Pythonic" way but this seems to work.

Index: amfast/remoting/channel.py
===================================================================
--- amfast/remoting/channel.py  (revision 526)
+++ amfast/remoting/channel.py  (working copy)
@@ -334,8 +334,9 @@
             amfast.logger.debug("Cleaning channel.")

         current_time = time.time() * 1000
-        for connection_id in self.connection_manager.iterConnectionIds():
-            self.cleanConnection(connection_id, current_time)
+        if self.connection_manager.iterConnectionIds():
+            for connection_id in self.connection_manager.iterConnectionIds():
+                self.cleanConnection(connection_id, current_time)

         if hasattr(self.subscription_manager, 'deleteExpiredMessages'):
             # TODO: better interface for deleting expired messages.
Index: amfast/remoting/memcache_connection_manager.py
===================================================================
--- amfast/remoting/memcache_connection_manager.py  (revision 526)
+++ amfast/remoting/memcache_connection_manager.py  (working copy)
@@ -126,7 +126,10 @@

     def iterConnectionIds(self):
         connection_ids = self.mc.get(self.CONNECTIONS_ATTR)
-        return connection_ids.__iter__() 
+        if connection_ids != None:
+          return connection_ids.__iter__()
+   else:
+          return None 

     # --- proxies for connection properties --- #

Original comment by cp...@wingsnwakes.com on 30 Jul 2010 at 4:10

GoogleCodeExporter commented 9 years ago
Thanks for the patch, I'll try to take a look at it this weekend.

Original comment by dthomp...@gmail.com on 30 Jul 2010 at 4:22

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r527.

Original comment by dthomp...@gmail.com on 31 Jul 2010 at 4:01