def test_mkdir(self): def mkdir_cb(foo): print 'mkdir callback', foo d1 = 'test' d2 = 'test/eio-test-dir' # ensure dirs don't exist: if os.path.exists(d2): os.rmdir(d2) if os.path.exists(d1): os.rmdir(d1) self.assertFalse(os.path.exists(d1)) eio.mkdir(d1, 0777, mkdir_cb) time.sleep(0.1) print 'poll', eio.poll() self.assertTrue(os.path.exists(d1)) self.assertFalse(os.path.exists(d2)) eio.mkdir(d2, 0777, mkdir_cb) time.sleep(2.1) print 'poll', eio.poll() self.assertTrue(os.path.exists(d2)) eio.rmdir(d2) self.assertFalse(os.path.exists(d2)) eio.rmdir(d1) self.assertFalse(os.path.exists(d1))
def event_loop(): #{ # // an event loop. yeah. # struct pollfd pfd; # pfd.fd = respipe [0]; # pfd.events = POLLIN; # try: p = select.poll() p.register(respipe[0], select.POLLIN) # printf ("\nentering event loop\n"); #print 'entering event loop' # while (eio_nreqs ()) while eio.nreqs(): # { # poll (&pfd, 1, -1); sys.stdout.write('.') sys.stdout.flush() p.poll(1000) # printf ("eio_poll () = %d\n", eio_poll ()); #print 'eio_poll () = %d' % eio.poll() eio.poll() except AttributeError: # no poll, stupidily wait 500ms time.sleep(0.5) while eio.nreqs(): sys.stdout.write('.') sys.stdout.flush() eio.poll()
d1 = 'test' d2 = 'test/eio-test-dir' # ensure dirs don't exist: if os.path.exists(d2): os.rmdir(d2) if os.path.exists(d1): os.rmdir(d1) self.assertFalse(os.path.exists(d1)) eio.mkdir(d1, 0777, mkdir_cb) time.sleep(0.1) print 'poll', eio.poll() self.assertTrue(os.path.exists(d1)) self.assertFalse(os.path.exists(d2)) eio.mkdir(d2, 0777, mkdir_cb) time.sleep(2.1) print 'poll', eio.poll() self.assertTrue(os.path.exists(d2)) eio.rmdir(d2) self.assertFalse(os.path.exists(d2)) eio.rmdir(d1) self.assertFalse(os.path.exists(d1)) print 'poll', eio.poll() time.sleep(0.1) print 'exiting'
def poll_eio(): while True: wait_read(respipe[0]) while eio.nreqs(): eio.poll() gevent.sleep()