python xmlrpc: cannot handle connection errors

X

xristoph

Hello everyone!

I am trying to set up a broker-worker system (one broker, multiple and
heterogeneous workers) in python for a local network (though possibly
also over inet). I am using SimpleXMLRPCServer and
xmlrpclib.ServerProxy for connections.

Whatever I do, after about 100,000 to 150,000 XMLRPCalls over a single
ServerProxy connection, I am getting a connection error (usually
"connection reset by peer"). I have tried deleting the ServerProxy,
setting up a new one and calling the function again when the error
occurs, but this does not change anything:

# this is the worker's secureRPC; the broker's works analogously
def worker_secureRPC(self, fname, args=None):
tries = 2 # raising the nr of tries does not change
anything
retval = None
for i in range(0,tries):
try:
fref = self.getfref(fname)
# returns a reference to
self.sender.fname
if (args==None):
retval = fref()
else:
retval = fref(*args)
except:
self.sender = None
time.sleep(1)
self.sender = ServerProxy("http://" + self.brokerHost + ":" +
str(self.brokerPort))
if (i>=(tries-1)):
raise


Then, thinking that maybe the "return" statement produces the error, I
tried doing error handling there as well (keep in mind that the
function might have been called already, so don't do the same action
twice):

def worker_foo(self, popcontainer, failed=[]):
self.lock.acquire()
if (len(failed) > 0):
while (len(failed) > 0):
failed.pop()
else:
do_stuff_in_new_thread()
self.lock.release()
try:
return True
except:
failed.append("failed")

The function foo gets called remotely after the set-up of the new
ServerProxy, but does produce the same error again! (socket.error:
connection reset by peer). Btw, another function sends the result back
to the Broker again via xmlrpc, resulting in asynchronous
communication, so we only need to return some bogus value here.

Am I missing sth obvious here, or why can I not re-build the
connection? What can I do to handle this error correctly?

cheers,

Christoph
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top