与前面的问题(如TypeError: argument of type 'int' is not iterable)不同,在我的例子中,似乎没有立即出现明显的索引问题。在
在下面的代码中,testcfg.agents
是主机名和/或IP地址的列表,testcfg.port
是{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!
我得到的确切例外是(去掉了对模块的各种回溯):
^{pr2}$我不明白这个错误是从哪里来的。当init_event.eventcommand
是一个iterable对象(一个列表)时,我通过xmlrpc
在其他代码中传递并返回了iterable对象,但没有遇到这个错误。我已经检查过意外的变量重用,我认为这也不是问题所在。我真的很想得到帮助!在
以下是此错误的完整回溯,以供参考:
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">
你可能需要传入一个iterable,比如一个整数列表。。。在
我想我已经解决了,至少部分解决了。显然远程函数只接受一个元组参数。改变
到
^{pr2}$似乎已经修复了这个错误。在
相关问题 更多 >
编程相关推荐