Something like asynchronous XML-RPC possible?

Laura Creighton lac at strakt.com
Sat Jan 25 07:28:57 EST 2003


[Will Stuyvesant]
> 
> I can think of one argument they will confront me with I do not have a
> good answer for.  It is the "blocking caller" or "inefficient thread
> creation" thing.   As Stuart guessed, the application is indeed sort
> of realtime, they want the caller to continue processing *immediately*
> after sending the event to the server.  The prototype I have now does
> send an event by means of an XML-RPC call in a separately created
> thread (just using pythons' nice ``thread.start_new()``) because it
> *has* to receive a return value from the server even though it will
> never look at it.  If they say that creating a thread for this is
> highly inefficient and a wrong design, what should my answer be?

They're right, this is inefficient.  So don't do this.

Instead, make one thread whose job is to attend to 'open connections'.
Make a Queue and pass your new connections to that thread.  If there
are no new connections, that thread will block.  If there are connections,
then you can process them one by one (if that is what you want) or use
select to get them going simultaneously (if that is what you want
instead).

Or you could use Pyro, Corba, Twisted -- something that is already
designed to send out requests and not wait for a response.

Or you could hack the server side to not send a response in the first
place.

Laura Creighton





More information about the Python-list mailing list