Changes by Winfried Plappert [EMAIL PROTECTED]:
--
nosy: +wplappert
___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3476
___
___
Python-bugs-list mailing
Antoine Pitrou [EMAIL PROTECTED] added the comment:
Here is a new patch which simply wraps the current BufferedWriter
methods with a lock. It has a test case, and Amaury's example works fine
too.
Martin, do you think it's fine?
(as for BufferedReader, I don't see the use cases for
Martin v. Löwis [EMAIL PROTECTED] added the comment:
The patch looks fine (as far as it goes).
I do think the same should be done to the reader: IO libraries typically
provide a promise that concurrent threads can read, and will get the
complete stream in an overlapped manner (i.e. each input
Antoine Pitrou [EMAIL PROTECTED] added the comment:
Both BufferedReader and BufferedWriter are now fixed in r65686.
Perhaps someone wants to open a separate issue for TextIOWrapper...
--
resolution: - fixed
status: open - closed
___
Python tracker
Martin v. Löwis [EMAIL PROTECTED] added the comment:
I don't think the proposed patch (file11012) makes it thread-safe, and I
believe you cannot get it thread-safe without using thread synchronization.
For example, if two threads simultaneously determine that there is still
space left (len(b) =
Antoine Pitrou [EMAIL PROTECTED] added the comment:
Hi,
Selon Martin v. Löwis [EMAIL PROTECTED]:
I don't think the proposed patch (file11012) makes it thread-safe, and I
believe you cannot get it thread-safe without using thread synchronization.
I should have precised that in the context
Antoine Pitrou [EMAIL PROTECTED] added the comment:
Attaching a new patch with better performance characteristics than my
previous one, and the non-blocking test rewritten in a sane way.
Some timeit runs:
-s import io; f=io.open('/dev/null', 'wb'); s=b'a'*1 for i in xrange(100):
f.write(s)
Martin v. Löwis [EMAIL PROTECTED] added the comment:
I should have precised that in the context of this issue, thread-safe does
not
mean produces perfectly correct output but simply does not raise exceptions
when using the same buffered object from two different threads.
In that case, I'm
Antoine Pitrou [EMAIL PROTECTED] added the comment:
Le vendredi 01 août 2008 à 21:51 +, Martin v. Löwis a écrit :
With the status quo, people have at least a chance of learning that the
library is not thread-safe. If the shallow problems are resolved, people
will cry FOUL loudly when they
Martin v. Löwis [EMAIL PROTECTED] added the comment:
Well, if that resolution is prefered, I think it should be integrated to
the builtin print function, rather than forcing users to monkeypatch it
(but a debugging facility directly calling sys.stdout.write or
equivalent will not be helped).
New submission from Antoine Pitrou [EMAIL PROTECTED]:
As discovered in #3139, io.BufferedWriter mutates the size of its
internal bytearray object. Consequently, invocations of write() from
multiple threads can produce exceptions when one thread gets a buffer to
the bytearray while the other
Antoine Pitrou [EMAIL PROTECTED] added the comment:
Here is a sample implementation (using a fixed-size bytearray) with test.
Amaury, would you like to take a look?
I'm a bit puzzled by the shady BufferedRandom semantics: though the
tests do pass, it's hard to say why e.g. BufferedRandom.tell()
Benjamin Peterson [EMAIL PROTECTED] added the comment:
It seems that as with the quadratic binary buffered reading, the best
solution is the list of bytes which should be especially helped by your
bytes joining optimization.
--
nosy: +benjamin.peterson
Antoine Pitrou [EMAIL PROTECTED] added the comment:
Selon Benjamin Peterson [EMAIL PROTECTED]:
Benjamin Peterson [EMAIL PROTECTED] added the comment:
It seems that as with the quadratic binary buffered reading, the best
solution is the list of bytes which should be especially helped by your
Benjamin Peterson [EMAIL PROTECTED] added the comment:
On Thu, Jul 31, 2008 at 9:36 AM, Antoine Pitrou [EMAIL PROTECTED] wrote:
I don't really know. The logic is quite different (and harder to get right)
than
in BufferedReader. I might try to write a list-of-bytes version and do some
15 matches
Mail list logo