I have an application which instantiates an xmlrpclib.ServerProxy
once, and then passes it to several threads (web application requests), which all perform XML/RPC calls simultaneously. This works well with python 2.6. With python 2.7, we're getting a lot of errors (ResponseNotReady
, CannotSendRequest
) as soon as we're in a multi-threaded environment.
# This code works well in python 2.6, and breaks in python 2.7.
import xmlrpclib
import thread
proxy = xmlrpclib.ServerProxy("http://localhost:5000/")
def fetch_users():
print proxy.getUsers()
for _ in range(10):
thread.start_new_thread(fetch_users, ())
while(1):
pass
What is the problem here, and is there a thread-safe way of re-using the ServerProxy-object?