我使用一個類的方法中的蟒蛇,並從我做pika的on_open_error_callback方法簽名是什麼樣子的?
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)
[[email protected] ~/house/test]$
我一直無法找到任何文件,顯示此回調的實際方法簽名。我懷疑它尋找方法的非類定義(即沒有自己作爲參數)。那是對的嗎?如果是這樣的話?那麼如何才能訪問類變量,以便我可以嘗試重新連接連接錯誤?
我想我首先要找的是我的方法簽名應該是什麼樣子?
在此先感謝