low level python read's
grzesiof at gmail.com
Sun Jan 7 16:44:50 CET 2007
I wanted to use python to test a simple character device (on linux) and
I'm running into strange behaviour of read..
I have a short buffer inside my device and the idea is that it blocks
read's when the buffer is empty. For reads that ask for more characters
that the buffer holds the device should return the number of bytes
In c i can write:
f = open("/dev/testdevice",O_RDWR);
and i see in my device, that everything is ok.
No I'd love to reproduce this in python..
f = open("/dev/testdevice", "r+",0) # for unbuffered access
..but now i see in the device log's that python issued 2 reads! One
that got the whole buffer (less then 1000 chars) and after that python
tries to read more! (and hangs in my device, since the buffer is
So how do i stop python from trying to be smart and just read *at most*
1000 chars and let it go if he(it?*) reads less?
p.s *is python a "he" or an "it"?
More information about the Python-list