[Twisted-Python] pb: callRemotes execute serially on server-side

David Karnowski dkarnows at gmail.com
Mon Jan 19 13:42:14 EST 2009

Hi all,

I'm having a client-side pb app call the same server-side function 10
times with this client-side code:

 def process_test(rootObject):
     for i in range(10):
         _logger.debug("Calling remote with arg: %d" % (i))
         deferred = rootObject.callRemote("test_it", i)
         deferred.addCallbacks(success, problem,
callbackKeywords={'i': i}, errbackKeywords={'i': i})

The server-side "remote_test_it" function takes 5 seconds to complete
(per call). I find the following. The first point is what I'd expect,
but points 2 & 3 are not:

1) The above for-loop completes asynchronously, with no blocking. It's
complete in a few-thousand milliseconds.
2) The server-side executes serially. The second client-side call to
"remote_test_it" doesn't start executing "test_it" on the server-side
until after the first call has finished. I'd have thought these 10
calls would occur in parallel (in separate server-side threads). No?
3) None of the callbacks you see in the above client-side for-loop get
executed until ALL 10 callRemotes have finished on the server-side.
e.g. the callRemote for the first loop iteration finishes on the
server-side in 5 seconds, but the associated client-side callback
isn't executed until after 50 seconds (after the 10th loop iteration's
server-side call finishes).

I'm just starting with Twisted. Are points 2 & 3 expected, and is
there a way for me to have them run in parallel rather than serially?


More information about the Twisted-Python mailing list