不同於像TypeError: argument of type 'int' is not iterable似乎沒有要在我的情況下,立即明顯問題索引以前的問題。的Python 3.2.2:在xmlrpc.client通話莫名的故障 - 「參數類型的‘詮釋’不是可迭代的」
在以下代碼中,testcfg.agents
是主機名和/或IP地址列表,而testcfg.port
是xmlrpc
調用應使用的端口。在Active Directory中的DSEvent
類模型事件,並DSEvent.eventcommand
是包含命令及其參數列表(通過xmlrpc
調用傳遞給代理,它使用subprocess
模塊時執行。)
# Create a list of agents to process events from
agent_list = []
for a in testcfg.agents:
agent_list.append(xmlrpc.client.ServerProxy("http://" + a + ':' + testcfg.port))
# Initial user creation:
for j in range(5):
init_event = DSEvent(type = 'add', is_important = True)
agent_eB = random.choice(agent_list)
agent_eB.execute(init_event.eventcommand) # This line throws the fault described below!
確切的例外,我」 (得到各種追溯到模塊剝離):
xmlrpc.client.Fault: <Fault 1: "<class 'TypeError'>:argument of type 'int' is not iterable">
我不明白這個故障可能來自哪裏。雖然init_event.eventcommand
是一個可迭代的對象(一個列表),我已經通過並在其他代碼中通過xmlrpc
返回了可迭代對象,而不會遇到此錯誤。我檢查過意外的可變重用,而且我也不認爲這是問題。我真的很喜歡這裏的一些幫助!
以供參考,在這裏是這個錯誤的完整回溯:
Traceback (most recent call last):
File "C:\Users\Administrator\Downloads\randeventmaker\randeventmakerengine.py",
line 861, in <module>
sproxy.execute(initializing_event.eventcommand)
File "C:\Python32\lib\xmlrpc\client.py", line 1095, in __call__
return self.__send(self.__name, args)
File "C:\Python32\lib\xmlrpc\client.py", line 1423, in __request
verbose=self.__verbose
File "C:\Python32\lib\xmlrpc\client.py", line 1136, in request
return self.single_request(host, handler, request_body, verbose)
File "C:\Python32\lib\xmlrpc\client.py", line 1151, in single_request
return self.parse_response(resp)
File "C:\Python32\lib\xmlrpc\client.py", line 1323, in parse_response
return u.close()
File "C:\Python32\lib\xmlrpc\client.py", line 667, in close
raise Fault(**self._stack[0])
xmlrpc.client.Fault: <Fault 1: "<class 'TypeError'>:argument of type 'int' is
not iterable">
我認爲,「各種回溯到模塊」會告訴你究竟是什麼嘗試迭代,這是不可迭代的,因此是一個很好的暗示回答這個問題.... – 2012-01-07 04:23:25
我已經追加了完全回溯到這個問題。 – Kudzu 2012-01-07 15:38:51