wuguobao / pybeanstalk

Automatically exported from code.google.com/p/pybeanstalk
0 stars 0 forks source link

Issue while running pybeanstalk within processing pools #9

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
While running pybeanstalk within python processing pools 
(http://pypi.python.org/pypi/processing), I get an exception 
traceback like this.

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/threading.py", line 460, in 
__bootstrap
    self.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/threading.py", line 440, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/Library/Python/2.5/site-packages/processing-0.52-py2.5-macosx-10.5-i386.egg/processing/pool.py", line 
207, in _handleTasks
    put(task)
  File "/Users/jeethurao/code/pybeanstalk/beanstalk/serverconn.py", line 96, in caller
    *getattr(protohandler, 'process_%s' % attr)(*args, **kw))
AttributeError: 'module' object has no attribute 'process___getnewargs__'

Here's a patch to fix this behavior.

diff --git a/beanstalk/serverconn.py b/beanstalk/serverconn.py
index ac3d8e9..4797d1d 100644
--- a/beanstalk/serverconn.py
+++ b/beanstalk/serverconn.py
@@ -91,6 +91,8 @@ class ServerConn(object):
     watchlist = property(_get_watchlist, _set_watchlist)

     def __getattr__(self, attr):
+        if attr.startswith('__') :
+            return object.__getattr__(self, attr)
         def caller(*args, **kw):
             return self._do_interaction(\
                 *getattr(protohandler, 'process_%s' % attr)(*args, **kw))

I've forked the pybeanstalk repo on github and added this and another trivial 
patch for a minor issue. ( http://github.com/woadwarrior/pybeanstalk/ )

Original issue reported on code.google.com by jeethu...@gmail.com on 19 Apr 2009 at 4:51