Re: [Python-Dev] thread semantics for file objects

2005-03-18 Thread Martin v. Löwis
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 ab

Re: [Python-Dev] thread semantics for file objects

2005-03-18 Thread stelios xanthakis
Jeremy Hylton wrote: On Thu, 17 Mar 2005 16:25:44 -0500, Aahz <[EMAIL PROTECTED]> wrote: On Thu, Mar 17, 2005, Jeremy Hylton wrote: Are the thread semantics for file objecst documented anywhere? I don't see anything in the library manual, which is where I expected to find it. It looks lik

Re: [Python-Dev] thread semantics for file objects

2005-03-18 Thread Jeremy Hylton
On Fri, 18 Mar 2005 07:57:25 +0100, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > Writing down all these properties does little good, IMO. This includes > your proposed property of file reads: anybody reading your statement > will think "of course it works this way - why even mention it". The thi

Re: [Python-Dev] thread semantics for file objects

2005-03-18 Thread Paul Moore
On Fri, 18 Mar 2005 07:57:25 +0100, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > The guarantee that "we" want to make is certainly stronger: if the > threads all read from the same file, each will get a series of "chunks". > The guarantee is that it is possible to combine the chunks in a way to >

Re: [Python-Dev] thread semantics for file objects

2005-03-17 Thread Martin v. Löwis
Jeremy Hylton wrote: It sounds like the weakest intended behavior we have is the one Tim reported: "provided the platform C stdio wasn't thread-braindead, then if you had N threads all simultaneously reading a file object containing B bytes, while nobody wrote to that file object, then the total n

Re: [Python-Dev] thread semantics for file objects

2005-03-17 Thread Jeremy Hylton
On Thu, 17 Mar 2005 23:57:52 +0100, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > Remember, you were asking what behaviour is *documented*, not what > behaviour is guaranteed by the implementation (in a specific version > of the implementation). Martin, I think you're trying to find more finesse

Re: [Python-Dev] thread semantics for file objects

2005-03-17 Thread Tim Peters
[Jeremy Hylton] ... > Universal newline reads and get_line() both lock the stream if the > platform supports it. So I expect that they are atomic on those > platforms. Well, certainly not get_line(). That locks and unlocks the stream _inside_ an enclosing for-loop. Looks quite possible for diff

Re: [Python-Dev] thread semantics for file objects

2005-03-17 Thread Martin v. Löwis
Jeremy Hylton wrote: Are the thread semantics for file objecst documented anywhere? Literally, the answer to your question is "no". I'm surprised that it does not, for example, guarantee that reads and writes are atomic, since CPython relies on fread and fwrite which are atomic. Where is the connec

Re: [Python-Dev] thread semantics for file objects

2005-03-17 Thread Aahz
On Thu, Mar 17, 2005, Tim Peters wrote: > > I think Aahz was on target here: > > NEVER, NEVER access the same file object from multiple threads, unless > you're using a lock. > > And here he went overboard: > > And even using a lock is stupid. > > ZODB's FileStorage is bristling wit

Re: [Python-Dev] thread semantics for file objects

2005-03-17 Thread Jeremy Hylton
On Thu, 17 Mar 2005 17:13:05 -0500, Tim Peters <[EMAIL PROTECTED]> wrote: > [Jeremy Hylton] > > Are the thread semantics for file objecst documented anywhere? > > No. At base level, they're inherited from the C stdio implementation. > Since the C standard doesn't even mention threads, that's all

Re: [Python-Dev] thread semantics for file objects

2005-03-17 Thread Jeremy Hylton
On Thu, 17 Mar 2005 23:04:16 +0100, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > Jeremy Hylton wrote: > >>>Are the thread semantics for file objecst documented anywhere? I > >>>don't see anything in the library manual, which is where I expected to > >>>find it. It looks like read and write are

Re: [Python-Dev] thread semantics for file objects

2005-03-17 Thread Tim Peters
[Jeremy Hylton] > Are the thread semantics for file objecst documented anywhere? No. At base level, they're inherited from the C stdio implementation. Since the C standard doesn't even mention threads, that's all platform-dependent. POSIX defines thread semantics for file I/O, but fat lot of go

Re: [Python-Dev] thread semantics for file objects

2005-03-17 Thread Martin v. Löwis
Jeremy Hylton wrote: Are the thread semantics for file objecst documented anywhere? I don't see anything in the library manual, which is where I expected to find it. It looks like read and write are atomic by virtue of fread and fwrite being atomic. Uncle Timmy will no doubt agree with me: the se

Re: [Python-Dev] thread semantics for file objects

2005-03-17 Thread Samuele Pedroni
Jeremy Hylton wrote: On Thu, 17 Mar 2005 16:25:44 -0500, Aahz <[EMAIL PROTECTED]> wrote: On Thu, Mar 17, 2005, Jeremy Hylton wrote: Are the thread semantics for file objecst documented anywhere? I don't see anything in the library manual, which is where I expected to find it. It looks like read a

Re: [Python-Dev] thread semantics for file objects

2005-03-17 Thread Jeremy Hylton
On Thu, 17 Mar 2005 16:25:44 -0500, Aahz <[EMAIL PROTECTED]> wrote: > On Thu, Mar 17, 2005, Jeremy Hylton wrote: > > > > Are the thread semantics for file objecst documented anywhere? I > > don't see anything in the library manual, which is where I expected to > > find it. It looks like read and

Re: [Python-Dev] thread semantics for file objects

2005-03-17 Thread Aahz
On Thu, Mar 17, 2005, Jeremy Hylton wrote: > > Are the thread semantics for file objecst documented anywhere? I > don't see anything in the library manual, which is where I expected to > find it. It looks like read and write are atomic by virtue of fread > and fwrite being atomic. Uncle Timmy wi

[Python-Dev] thread semantics for file objects

2005-03-17 Thread Jeremy Hylton
Are the thread semantics for file objecst documented anywhere? I don't see anything in the library manual, which is where I expected to find it. It looks like read and write are atomic by virtue of fread and fwrite being atomic. I'm less sure what guarantees, if any, the other methods attempt to