views:

68

answers:

1

I have a Python-driven web interface powered by Apache 2.2 with mod_python and Python 2.4. I need to make an asynchronous process appear synchronous to users of this web interface.

When users access one module on this website:

  1. An external SOAP interface will be contacted with a unique identifier and will respond with a number N
  2. The external interface will respond asynchronously by contacting a SOAP server on my machine between 1 and 10 times (the number N tells us how many responses we will receive)

I need to somehow aggregate these responses and pass them to the original module which will display the information back to the user. The goal is to make the process appear synchronous to the user.

What is the best way to handle this synchronization issue? Is this something Twisted would be well-suited for?

I am not restricting myself to Python for the solution, though it is preferred because everything else on the server is in Python. I prefer a solution that is both scalable and will take a minimal amount of programming time (though I understand that these attributes are somewhat at odds).

A: 

Maybe you can use Orbited to get ajax push with long-lived HTTP connections to your web clients. Orbited is based on Twisted, so I think it makes sense to look at if you already know Twisted. Have a look at this tutorial to get started.

aeby
Unfortunately the interface accessing the mod_python module will not be accessed from a web browser but from another web interface so a JavaScript solution will not work.I actually do not know Twisted beyond playing with it very briefly a couple years ago but I am willing to learn it if it will help me arrive at a simple solution.
Trey
So, if it's not web based its a little easier I think. You could write a twisted server that accepts connections from your client, connect the SOAP interface and polls the state of the responses (I assume that they are stored somewhere in a database). If you got all responses, write the answer back to the open client connection and quit. If the client protocol is HTTP you could also look at http://www.tornadoweb.org/
aeby