Question about xmlrpc and threading
Martin P. Hellwig
mhellwig at xs4all.nl
Thu Feb 16 18:43:15 EST 2006
David Hirschfield wrote:
<cut>
> My question was whether this is allowed? Can two calls be made via the
> same ServerProxy instance while a request is already underway?
>
> Clearer?
> -Dave
>
<cut>
Much, and my preliminary answer is, I have no clue :-)
But knowing that python will throw an exceptions when something is not
allowed and that we can analyze if the logic of the program breaks we do
can build a test case!
I've taken the opportunity, but I might be as wrong was I am right (and
still won't know which one it was):
So, I expect that when something un-allowed happens it will throw an
exception and otherwise that the workflow on the server should resemble
the work flow on the client:
So i created an async server with only one function (which is even worse
then your question):
def doSomething(self,threadID):
randomWait= random.randrange(0,10)
time.sleep(randomWait)
print("Thread %s has slept for %s seconds" % threadID,randomWait))
returnValue = "Thread %s has slept for %s seconds" % (threadID,randomWait)
return returnValue
and a threaded client:
class testThread(threading.Thread):
def run(self):
xmlrpclib.server = xmlrpclib.ServerProxy("http://localhost:8080")
x=xmlrpclib.server
print(x.doSomething(self.getName()))
for i in range(100):
testThread().start()
So when I run that I except that the output on the server is the same as
the one on the client with an error margin within the second range
(which would indicate that a certain thread has been scheduled a little
earlier then the other), guess what the output of the two was?
Well I say this much, most of them where in sync (within the error
margin) so I conclude that your question is answered with , yes you can
have a call when another one is processed without intervening with each
other( if you want that).
--
mph
More information about the Python-list
mailing list