Hi,
there are many ways of solving the problem of finite buffer sizes when
talking to a subprocess. I'd usually suggest using select() but today I
was looking for a more readable/understandable way of doing this. Back
in 1997 Guido himself posted a very nice solution, write your input to
a temporary file and then read that from your new process. His posting
can be found here:
http://groups.google.com/group/comp....b0a786d87ba23b
Being a bit puzzled over this usage of tempfile I read its
documentation and as expected it says:
[...] The file is created using mkstemp. It will be destroyed as soon
as it is closed (including an implicit close when the object is garbage
collected). [...] your code should not rely on a temporary file created
using this function having or not having a visible name in the file
system.
so how was Guido planning to get the contents of the file after closing
it? Should we do a tf.flush() instead of the close to ensure everything
is written, then read from it, using subprocess.Popen(....,stdin=tf,..)
and only close it afterwards?
Is it correct to assume that a named temporary file will be (sometimes)
accesible while it has not been closed yet?
cheers,
tim