Threading problem

Robert Cragie robert.cragie at *nospam*asisi.co.uk
Thu Aug 3 19:29:21 EDT 2000


I am having a problem with using threading and hope someone might be able to
help me. I'm using Python 1.5.2 on Redhat Linux 6.1 (Kernel 2.2.12-20). It
might be a bit off-topic in that it's concerning a device driver I have
written too.

I have written a device driver which blocks on read() waiting for data. To
test this, I have written a Python app. using wxPython. To perform the read,
I spawn a thread using the 'threading' module, and this then does a blocking
read() etc. This all seems to work fine. However the problem comes when I
try to close the device from the main GUI thread. The spawned thread is
blocked in read() using interruptible_sleep_on() a wait_queue. The close()
function calls a wake_up_interruptible() to unblock the read() call, which
will then exit with EINTR. That's the theory...

In practise, the close() function never appears to be called. I am using the
'os' module to do low level calls, and I call os.close() which seems to
return, but without having called the underlying device driver close() (or
release()) function. This is my assumption based on the fact that I am doing
a printk() for diagnostics which does not appear, and also that the read()
does not unblock.

If I do a subsequent ctrl-C (SIGKILL), the read() call then unblocks,
however the rest of the application gets a bit confused.

What I would like to know is why the underlying device driver close() is not
apparently being called, or if there is some mystery surrounding the
wake_up_interruptible() call.

TIA

Robert Cragie







More information about the Python-list mailing list