Advice wanted: asynch I/O on unix

Erno Kuusela erno-news at erno.iki.fi
Mon Jul 23 21:42:52 EDT 2001


In article <owen-66B4BF.09573623072001 at nntp4.u.washington.edu>,
"Russell E. Owen" <owen at astro.washington.edu> writes:

| 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 one finishes,
|   processes the data, deallocate the buffer,
|   and allocate a new buffer and queue an aioread on it
| writing works similarly

| It would be nicest to end up with as little C code as possible (i.e. 
| move most of this functionality into Python). 

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

if not, you can still use python threads.

if you want to keep the c library, the lowest overhead method
might be to start a separate process for the parallel
port reading process and have a bit of c send things to
your python program (for example with pipes.)

| Ideally, I'd like to start a read into a 
| big FIFO, then check every once in awhile and process the data that has 
| arrived.

that's approximately what select lets you do (from many files at once).

  -- erno



More information about the Python-list mailing list