Issue31976
Created on 2017-11-08 04:27 by benfogle, last changed 2017-11-10 21:05 by pitrou. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 4331 | merged | benfogle, 2017-11-08 04:35 | |
| Messages (3) | |||
|---|---|---|---|
| msg305803 - (view) | Author: Benjamin Fogle (benfogle) * | Date: 2017-11-08 04:27 | |
To reproduce:
```
import threading
import io
import time
import _pyio
class MyFileIO(io.FileIO):
def flush(self):
# Simulate a slow flush. Slow disk, etc.
time.sleep(0.25)
super().flush()
raw = MyFileIO('test.dat', 'wb')
#fp = _pyio.BufferedWriter(raw)
fp = io.BufferedWriter(raw)
t1 = threading.Thread(target=fp.close)
t1.start()
time.sleep(0.1) # Ensure t1 is sleeping in fp.close()/raw.flush()
fp.write(b'test')
t1.join()
```
_pyio.BufferedWriter ignores the error completely rather than throwing a ValueError("write to closed file").
|
|||
| msg306048 - (view) | Author: Antoine Pitrou (pitrou) * | Date: 2017-11-10 21:03 | |
New changeset 9703f092abc0259926d88c7855afeae4a78afc7d by Antoine Pitrou (benfogle) in branch 'master': bpo-31976: Fix race condition when flushing a file is slow. (#4331) https://github.com/python/cpython/commit/9703f092abc0259926d88c7855afeae4a78afc7d |
|||
| msg306049 - (view) | Author: Antoine Pitrou (pitrou) * | Date: 2017-11-10 21:04 | |
Thank you for posting this Benjamin. As I said on the PR, I don't think I want to backport this to 3.6, as it is always delicate to reason about subclassing and threads. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2017-11-10 21:05:15 | pitrou | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2017-11-10 21:04:47 | pitrou | set | messages:
+ msg306049 versions: - Python 3.6 |
| 2017-11-10 21:03:43 | pitrou | set | nosy:
+ pitrou messages: + msg306048 |
| 2017-11-08 21:32:58 | pitrou | set | nosy:
+ martin.panter |
| 2017-11-08 21:32:38 | pitrou | set | nosy:
+ benjamin.peterson, stutzbach |
| 2017-11-08 04:53:08 | benfogle | set | type: crash |
| 2017-11-08 04:35:45 | benfogle | set | keywords:
+ patch stage: patch review pull_requests: + pull_request4287 |
| 2017-11-08 04:27:27 | benfogle | create | |