Skip to content

Instantly share code, notes, and snippets.

@schmir
Created October 7, 2010 22:42
Show Gist options
  • Save schmir/616045 to your computer and use it in GitHub Desktop.
Save schmir/616045 to your computer and use it in GitHub Desktop.
#! /usr/bin/env python
import gevent.monkey; gevent.monkey.patch_all()
import gevent, fcntl, os
def doit():
count = 0
while 1:
count += 1
print count
gevent.sleep(1)
f = open("bla")
fcntl.fcntl(f.fileno(), fcntl.F_SETFL, os.O_NONBLOCK)
gevent.spawn(doit)
while 1:
gevent.socket.wait_read(f.fileno())
d = os.read(f.fileno(), 4096)
if not d:
break
print repr(d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment