Message245107
The BufferedReader class is documented as being thread safe: <https://docs.python.org/dev/library/io.html#multi-threading>. Some experimentation suggests that checking the “raw.closed” property is not actually serialized, but that raw.readinto() calls are serialized. I don’t think this is a big problem in practice, so I think BZ2File would remain as thread-safe as BufferedReader is.
But Serhiy’s point is definitely valid about the classes breaking the iterator protocol. FWIW I originally made this patch to satisfy my personal curiosity about why wrapping a second BufferedReader made things so much faster. Now I accept it is partly due to the overhead of the extra LZMAFile.readline() to BufferedReader.readline() delegation. Maybe it is not even worth optimizing around this kind of overhead, so I would even be happy to drop this patch and close the issue. |
|
Date |
User |
Action |
Args |
2015-06-10 03:07:25 | martin.panter | set | recipients:
+ martin.panter, rhettinger, pitrou, vstinner, larry, nadeem.vawda, eric.araujo, Arfrever, serhiy.storchaka, Michael.Fox |
2015-06-10 03:07:25 | martin.panter | set | messageid: <1433905645.22.0.923846653636.issue18003@psf.upfronthosting.co.za> |
2015-06-10 03:07:25 | martin.panter | link | issue18003 messages |
2015-06-10 03:07:24 | martin.panter | create | |
|