[Python-Dev] thread semantics for file objects
"Martin v. Löwis"
martin at v.loewis.de
Fri Mar 18 19:41:35 CET 2005
stelios xanthakis wrote:
> I think that when two threads write to the same fd without
> syncronization, the result is not
> deterministic anyway. In the case they are reading from the same fd,
> even worse! (and therefore
> the input cannot be useful to any serious algorithm)
Yes, but we are not talking about the same fd. Instead, we talk about
the same FILE*. A thread-safe libc guarantees (AFAIK) that the data
passed to fwrite are appended as a whole. This, in turn, means that
the data passed to Python's file.write are also appended as a whole.
I'm pretty sure this property also holds on Windows.
More information about the Python-Dev