Created
March 22, 2012 23:58
-
-
Save jhalcrow/2165629 to your computer and use it in GitHub Desktop.
Gevent server-client livelock
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
import gevent.monkey; gevent.monkey.patch_all() | |
import gevent.server | |
from BaseHTTPServer import BaseHTTPRequestHandler | |
import urllib2 | |
class DummyHTTPServer(gevent.server.StreamServer): | |
def handle(self, sock, addr): | |
handler = DummyHTTPHandler(sock, addr, self) | |
try: | |
handler.setup() | |
handler.handle() | |
finally: | |
handler.finish() | |
class DummyHTTPHandler(BaseHTTPRequestHandler): | |
def do_GET(self): | |
self.send_response(200) | |
self.end_headers() | |
self.wfile.write("blah") | |
server = DummyHTTPServer(('',10000)) | |
server.start() | |
test = urllib2.urlopen('http://localhost:10000').read() | |
print test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment