Could WSGI handle Asynchronous response?

E

est

I am writing a small 'comet'-like app using flup, something like this:


def myapp(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
return ['Flup works!\n'] <-------------Could this be part
of response output? Could I time.sleep() for a while then write other
outputs?

if __name__ == '__main__':
from flup.server.fcgi import WSGIServer
WSGIServer(myapp, multiplexed=True, bindAddress=('0.0.0.0',
8888)).run()


So is WSGI really synchronous? How can I handle asynchronous outputs
with flup/WSGI ?
 
E

est

I am writing a small 'comet'-like app using flup, something like this:

def myapp(environ, start_response):
    start_response('200 OK', [('Content-Type', 'text/plain')])
    return ['Flup works!\n']        <-------------Could this be part
of response output? Could I time.sleep() for a while then write other
outputs?

if __name__ == '__main__':
    from flup.server.fcgi import WSGIServer
    WSGIServer(myapp, multiplexed=True, bindAddress=('0.0.0.0',
8888)).run()

So is WSGI really synchronous? How can I handle asynchronous outputs
with flup/WSGI ?

figured out myself :blush: :blush:

def demo_app(environ,start_response):
from StringIO import StringIO
stdout = StringIO()
print >>stdout, "Hello world!"
print >>stdout
h = environ.items(); h.sort()
for k,v in h:
print >>stdout, k,'=',`v`
k=start_response("200 OK", [('Content-Type','text/plain')])
for x in range(1, 100):
k(str(x))
time.sleep(1)
return [stdout.getvalue()]

This function-programming style is very odd :) ................and
PEP 333 document is so hard for a newbie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,130
Latest member
MitchellTe
Top