GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — bpo-31976: Fix race condition when flushing a file is slow. by benfogle · Pull Request #4331 · python/cpython Conversation
|
| with self._write_lock: | ||
| if self.raw is None or self.closed: | ||
| return | ||
| try: |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This doesn't look right. The close() method should take the lock once, not take it three times in a row (one of them implicit in flush()). Note _flush_unlocked() can help you here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
That made a bunch of tests (test_flush_error_on_close, etc.) fail since close() no longer calls flush() if the file object is subclassed or fileobj.flush is set to something.
This is actually the same behavior as buffered_close in the C implementation. I have added a comment to that effect.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if (!ENTER_BUFFERED(self)) | ||
| return NULL; | ||
|
|
||
| if (IS_CLOSED(self)) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment and a reference to the bug entry here?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| self.assertTrue(b.closed) | ||
|
|
||
| def test_slow_close_from_thread(self): | ||
| rawio = self.SlowFlushRawIO() |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment pointing to the bug entry here?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It looks like you forgot to address this comment.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Ah, whoops. Thank you.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| bufio = self.tp(rawio, 8) | ||
| t = threading.Thread(target=bufio.close) | ||
| t.start() | ||
| time.sleep(0.1) # Long enough that t is sleeping in bufio.close() |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
You could probably use an Event that you would set in SlowFlushRawIO.flush() instead.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I have made the requested changes; please review again |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for making the requested changes! @pitrou: please review the changes made to this pull request. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I have made the requested changes; please review again. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for making the requested changes! @pitrou: please review the changes made to this pull request. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks. I'm inclined to merge this after CI approval. I'm not sure I want to backport it to 3.6, though, because there is a tiny but non-zero chance that this might break some odd usage somewhere and I don't want that to happen in a bugfix release. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.