XMLRPC calls don't work in threads, or rather, they don't play well with others ! (help)
Steve Ludtke
sludtke at bcm.tmc.edu
Mon Sep 30 00:22:41 EDT 2002
Hi. I've been trying to write a python app that makes somewhat
time-consuming XMLRPC calls. I planned to have several calls going at
once using threads, but it seems like something in the XMLRPC client
code isn't releasing the python interpreter lock properly. That is, as
soon as the XMLRPC call is made, none of the other threads do anything
until it returns. Just to make sure this was what was happening, I wrote
a little test thread that prints out messages every half-second, and
indeed, as soon as an xmlrpc call is made, nothing happens. This code
needs to be cross-platform compatible, so I'm rather leery of editing
any of the associated C source. Anyone have any ideas. Is there
something I can do at the Python level to deal with this issue ? TIA
PS - here's the code for the thread that doesn't seem to release:
class getThread(threading.Thread):
def __init__(self,queue,login):
threading.Thread.__init__(self)
self.queue=queue
self.login=login
self.transport=xmlrpclib_auth.
BasicAuthTransport(self.login[1],self.login[2])
def run(self):
while (1):
item=self.queue.get(1)
if (item=="EXIT") : return
server=xmlrpclib_auth.Server(self.
login[0]+item.idpath(),self.transport)
try:
lst=server.do_list()
# processing omitted
nv=server.values()
# more processing omitted
except:
#error processing
Both of the server.() calls prevent other threads from running
More information about the Python-list
mailing list