Created
March 7, 2012 16:08
-
-
Save yangjuven/1994035 to your computer and use it in GitHub Desktop.
Test gevent.queue in web.py.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf8 -*- | |
import web | |
import gevent | |
from gevent import queue | |
from gevent.timeout import Timeout | |
from gevent.hub import Waiter | |
from gevent.pywsgi import WSGIServer | |
from gevent import monkey | |
monkey.patch_all() | |
q = queue.Queue() | |
urls = ( | |
'/', 'push' | |
) | |
class push(object): | |
def GET(self): | |
q.put("hello") | |
def starthandler(): | |
while True: | |
print q.get() | |
if __name__ == "__main__": | |
gevent.spawn(starthandler) | |
application = web.application(urls, {'push': push}).wsgifunc() | |
WSGIServer(('', 8088), application).serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment