Advice wanted: asynch I/O on unix

Russell E. Owen owen at astrono.junkwashington.emu
Tue Jul 24 18:01:53 CEST 2001

In article <ku4rs3yueb.fsf at>,
 Erno Kuusela <erno-news at> wrote:

>In article <owen-66B4BF.09573623072001 at>,
>"Russell E. Owen" <owen at> writes:

While I'm replying, here's a minor correction to the description:

>| The present C program works as follows:
>| - open the parallel port as a file-like device (and config with ioctl)
>| - allocate some buffers
>| - call aioread to start reading into one buffer
>| - call aioread to queue a read into a 2nd buffer
>| - repeatedly poll the aioreads:
      - when a read finishes, allocates a new buffer
        and queues an aioread into it
     - returns the finished buffer for processing
       (which is done asynchronously)
>| writing works similarly

>unix character devices often support select(), if that works
>it would probably be easiest (look in the select module).

The main problem is going to be how to buffer data until it can be read. 
the parallel port card has no buffering of its own. Hence the complex 
process outlined above.

I was hoping unix and/or Python had some nice way to "magically" connect 
an unbuffered input device to a FIFO buffer and make it look like a 
socket, so I could use select and/or aynchcore.

I'm starting to dout that's practical. The C code we are presently using 
is only semi-asynchronous. Reads happen in their own thread (due to 
aioread), but one has to poll often enough to make sure a new buffer is 
allocated and a new read queued before the current read is finished. 
However, the card also includes a C library that MAY be usaable in some 
form, and may do the whole buffering thing asynchronously, which would 
be great.

-- Russell

P.S. Any advice regarding using "aioread", etc. vs "aio_read", etc.? 
This is on Solaris 8. "aio_read", etc. seems to be the standard Posix 
way of doing asynch I/O. I have no idea where "aioread", etc. come from, 
but it's what the existing C code uses. At first glance, the interface 
to aio_read looks a bit better, but I'd hate to pick something that was 
buggy or deprecated.

More information about the Python-list mailing list