我想使用Python RPC传递一些数据。我得到了正确的结果但也出错了。
xmlrpclib.Fault :: float()的文字无效:127.0.0.1“>。
我没有改变任何事情突然得到了错误。当我尝试使用PRC api传递数据时,它看起来像参数问题。但我仍然没有得到它。
def election_stop():
time.sleep(5)
while 1:
global candidate_ids,candidate_adds,candidate_ports,lessthan
if take_over==True and lessthan<=devices_attached:
index_=candidate_ids.index(max(candidate_ids))
add_s=candidate_adds[index_]
port_s=candidate_ports[index_]
print candidate_adds
print "[Gateway]"+str(add_s)+str(port_s)+"win"
try:
proxy = xmlrpclib.ServerProxy("http://"+add_s+":"+str(port_s)+"/")
ret = proxy.elec_recv("WIN",str(port_s),str(add_s),"you win pls takeover")
#ret = proxy.elec_recv("LEADER",candidate_ports[0:lessthan],candidate_adds[0:lessthan],candidate_ids[0:lessthan])
ret = proxy.elec_recv("LEADER",candidate_ports[0:lessthan],candidate_adds[0:lessthan],candidate_ids[0:lessthan])
break
except socket_error,exceptions.ValueError:
print socket_error
continue
return "stop"
Traceback (most recent call last):
File "./gateway.py", line 341, in <module>
election_stop()
File "./gateway.py", line 155, in election_stop
ret = proxy.elec_recv("LEADER",candidate_ports[0:lessthan],candidate_adds[0:lessthan],candidate_ids[0:lessthan])
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1224, in __call__
return self.__send(self.__name, args)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1578, in __request
verbose=self.__verbose
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1264, in request
return self.single_request(host, handler, request_body, verbose)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1297, in single_request
return self.parse_response(response)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1473, in parse_response
return u.close()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 793, in close
raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault 1: "<type 'exceptions.ValueError'>:invalid literal for float(): 127.0.0.1">
答案 0 :(得分:0)
您将参数"127.0.0.1"
传递给服务器上预期类型为float
的参数的函数。