我正在使用 python,并且在我做的一个类的方法中
self.connection = pika.SelectConnection(
self.connectionParameters,
on_open_callback=self.onConnected,
on_open_error_callback=self.onConnectionError,
on_close_callback=self.onConnectionClosed,
stop_ioloop_on_close=False)
在我的源代码中,我将方法声明为(在一个类中):
def onConnectionError(self):
"""
@summary: Called if the connection to rabbit is unavailable. Attempt to connect to one of
the many backup servers.
@return: ??
"""
但是在运行时我收到以下错误:
Traceback (most recent call last):
File "SpaceListener.py", line 218, in <module>
cacheTime=args.timeout)
File "SpaceListener.py", line 88, in __init__
logger=self.logger)
File "/home/centos/house/tes/castExchangeScan.py", line 108, in __init__
stop_ioloop_on_close=False)
File "build/bdist.linux-i686/egg/pika/adapters/select_connection.py", line 51, in __init__
File "build/bdist.linux-i686/egg/pika/adapters/base_connection.py", line 62, in __init__
File "build/bdist.linux-i686/egg/pika/connection.py", line 590, in __init__
File "build/bdist.linux-i686/egg/pika/connection.py", line 707, in connect
File "build/bdist.linux-i686/egg/pika/callback.py", line 61, in wrapper
File "build/bdist.linux-i686/egg/pika/callback.py", line 92, in wrapper
File "build/bdist.linux-i686/egg/pika/callback.py", line 232, in process
TypeError: onConnectionError() takes exactly 1 argument (2 given)
[centos@localhost ~/house/test]$
我一直无法找到任何显示此回调的实际方法签名的文档。我怀疑它在寻找方法的非类定义(即没有 self 作为参数)。那是对的吗?如果是这样的话?那么如何访问类变量,以便在连接错误时尝试重新连接?
我想我首先要寻找的是我的方法签名应该是什么样的?
提前致谢