wsgi, ajax, and multiple requests
Frank Millman
frank at chagford.com
Thu Feb 10 02:30:10 EST 2011
More information about the Python-list mailing list
Thu Feb 10 02:30:10 EST 2011
- Previous message (by thread): wsgi, ajax, and multiple requests
- Next message (by thread): PyCon 2011 news - going strong, sign up today!
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Frank Millman wrote: > Hi all > > I have a question about wsgi. > > As far as I can tell from the spec and from the reference implementation, > wsgi requires that each request from the client is responded to by one or > more headers, followed by the response body. It is then ready to handle > the next request. > > 99% of the time this is fine, but I have a situation where I need to vary > this, and I cannot see how to do it. Here is the scenario. > > I am dabbling with writing an ajax-style app. On occasion, I want to send > more than one message from the client to the server. It is important that > the server processes the messages in the same order that they are > generated. I have found that the Safari browser does not always send them > in the correct sequence. > > I found an article on the subject - > > http://www.sitepen.com/blog/2009/02/27/deterministic-clientserver-interaction/ > > It explains that you can never guarantee that the messages will arrive in > the same order, with *any* browser. Maybe I was lucky with the other ones. > It goes on to say that, if the order is important, you must include a > header with a sequential counter, and the server must check the sequence. > If received out of sequence, it must queue the one received, wait for the > correct one, and then process them both in the correct order. > > So the question is, how can I achieve this with wsgi? If I detect that I > have received a request out of sequence, I can queue the request, and send > an empty response. When I receive the correct request, I can process it, > call start_response(), and return the response body, but I cannot figure > out how to get back to process the queued request. > As both client and server are under my control, I have realised that there is a simple solution. On the client side, if there is more than one message to be sent, I pack them into an array, and send them in one request. The server receives the request, unpacks the array, and processes each message in turn. It should work reliably, and I save a round-trip into the bargain. Thanks for the replies - they all help in getting the little grey cells working. Frank
- Previous message (by thread): wsgi, ajax, and multiple requests
- Next message (by thread): PyCon 2011 news - going strong, sign up today!
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list