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 — Delay closing SubprocessStreamProtocol's Transport until all pipes are closed. by sethmlarson · Pull Request #485 · python/asyncio
This repository was archived by the owner on Nov 23, 2017. It is now read-only.
ConversationI believe this change fixes #484. Delays the closing for I haven't run tests or created a test for this exact issue but I will create a few tests later.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Delays the closing for `SubprocessStreamProtocol._transport` until all pipes have been closed and the process has exited rather than just the process exiting. This allows for reading data from the subprocess that is still pending in the pipe after the process has exited.
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Member
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Member
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
|
There was an error while loading. Please reload this page.
|
Sorry, won't do it again. I added a simple test that fails on old build and passes with the proposed change. I presume it's okay to have a test that doesn't assert anything, just to make sure that no errors are thrown? The test is taken pretty much 1-to-1 with the attached issue. I'm sure I can come up with a few more tests if more tests are required. :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I can confirm that this pull request fixes my issue #484 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| def _maybe_close_transport(self, fd): | ||
| if fd in self._pipe_fds: | ||
| self._pipe_fds.remove(fd) | ||
| if len(self._pipe_fds) == 0: |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this if len(...) be dedented?
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.
I guess that's true. My logic is we know that if nothing gets removed it won't be closed.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
...removal from fd list does not occur.
| self._limit = limit | ||
| self.stdin = self.stdout = self.stderr = None | ||
| self._transport = None | ||
| self._pipe_fds = [-1] |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
What does -1 mean 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.
I should probably add a comment. -1 is just the token for "process_exited" meaning we won't close a Transport until the process exits and all the pipes are done.
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.
Should I use a better sentinel object than -1?
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, interesting. I'd add a separate boolean attribute for that.
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.
Sure thing!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| reader.feed_eof() | ||
| else: | ||
| reader.set_exception(exc) | ||
| self._maybe_close_transport(fd) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I'd simply always call this method in pipe_connection_lost. Makes the code simpler to follow, and the logic with if statements should be (as they currently are) in _maybe_close_transport.
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.
Sure, just dedent that line then?
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.
yep.
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.
Alright, just wanted to make sure I was understanding that comment correctly. :)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
..._pipe_fds and change interface of _maybe_close_transport to not take an fd.
|
Can you please close this PR and make a new one to http://github.com/python/cpython (with a link to this discussion and review). It would make merging this way easier for me. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
So I made another change to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
@1st1 Oh, sure! Can I do this when I'm home from work? Don't have my actual environment all setup here, making do with the GitHub web interface. :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I like it now. Thanks for opening the new PR! I'll close this one. |
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.