Bidirectional communication through pipes: read/write popen()

Hrvoje Niksic hniksic at srce.hr
Sun Oct 17 13:20:54 EDT 1999


"Tim Evans" <tre17 at student.canterbury.ac.nz> writes:

> Looks good.  Could this also be done using threads?

Probably.  But this wouldn't work on machines without threading
support, and the task is just too basic to *require* threads.

I don't buy threads as a buzzword -- I believe my particular problem
is solved much more naturally using an helper process.  The additional
process touches very little data and modifies none, so COW should make
it inexpensive.  My timings show that this is indeed the case.

> create two threads, one for reading and the other for writing.  Then
> you can pass strings to the writing thread and get back the buffered
> result from the reading thread.  This allows interactive
> communication without the danger of deadlocks.

I think deadlocks can occur as long as there is the writing and
reading thread/process depend on each other.




More information about the Python-list mailing list