Example #1
0
def do_io(n_megs, use_eio=False):

    r = os.open("/dev/urandom", os.O_RDONLY)

    print "\nreading %s megs from /dev/urandom" % n_megs

    if use_eio:
        eio.init(want_poll, done_poll)

        r_event = Event()

        def set_r_event(result):
            r_event.set()

        buf = eio.read(r, 1024 * 1024 * n_megs, 0, set_r_event)

        print "waiting"
        r_event.wait()
    else:
        buf = os.read(r, 1024 * 1024 * n_megs)
    print "\ndone."

    gevent.sleep(0.5)
Example #2
0
File: demo_port.py Project: tmc/eio
    if hasattr(os, 'getuid'):
        eio.chown('eio-test-dir', os.getuid(), os.getgid())
#      eio_fchown (last_fd, getuid (), getgid (), 0, res_cb, "fchown");
        eio.fchown(last_fd, os.getuid(), os.getgid())
#      eio_fchmod (last_fd, 0723, 0, res_cb, "fchmod");
        eio.fchmod(last_fd, 0723, 0)
#      eio_readdir ("eio-test-dir", 0, 0, readdir_cb, "readdir");
#      eio_readdir ("/nonexistant", 0, 0, readdir_cb, "readdir");
#      eio_fstat (last_fd, 0, stat_cb, "stat");
#      eio_write (last_fd, "test\nfail\n", 10, 4, 0, res_cb, "write");
    eio.write(last_fd, 'test\nfail\n', 4)
#      event_loop ();
    event_loop()
#
#      eio_read (last_fd, 0, 8, 0, EIO_PRI_DEFAULT, read_cb, "read");
    eio.read(last_fd, 8, 0, read_callback)
#      eio_readlink ("eio-test-dir/eio-symlink", 0, res_cb, "readlink");
    event_loop()
#
#      eio_dup2 (1, 2, EIO_PRI_DEFAULT, res_cb, "dup"); // dup stdout to stderr
    eio.dup2 (1, 2) # dup stdout to stderr
#      eio_chmod ("eio-test-dir", 0765, 0, res_cb, "chmod");
    eio.chmod('eio-test-dir', 0765)
#      eio_ftruncate (last_fd, 9, 0, res_cb, "ftruncate");
    eio.ftruncate(last_fd, 9)
#      eio_fdatasync (last_fd, 0, res_cb, "fdatasync");
    eio.fdatasync(last_fd)
#      eio_fsync (last_fd, 0, res_cb, "fsync");
    eio.fsync(last_fd)
#      eio_sync (0, res_cb, "sync");
    eio.sync()