| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -1147,22 +1147,6 @@ def gen(): | |
| res = loop.run_until_complete(task) | ||
| self.assertEqual(res, "ok") | ||
|
|
||
| def test_wait_for_cancellation_race_condition(self): | ||
|
Comment thread
Copy link
Copy Markdown
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityDoes this test now fail if it wasn't removed?
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityExactly. The test is incorrect (the task must raise) and it doesn't reproduce original problem.
Sorry, something went wrong.
eIGato reacted with thumbs up emoji
All reactions
|
||
| def gen(): | ||
| yield 0.1 | ||
| yield 0.1 | ||
| yield 0.1 | ||
| yield 0.1 | ||
|
|
||
| loop = self.new_test_loop(gen) | ||
|
|
||
| fut = self.new_future(loop) | ||
| loop.call_later(0.1, fut.set_result, "ok") | ||
| task = loop.create_task(asyncio.wait_for(fut, timeout=1)) | ||
| loop.call_later(0.1, task.cancel) | ||
| res = loop.run_until_complete(task) | ||
| self.assertEqual(res, "ok") | ||
|
|
||
| def test_wait_for_waits_for_task_cancellation(self): | ||
| loop = asyncio.new_event_loop() | ||
| self.addCleanup(loop.close) | ||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| :meth:`asyncio.wait_for` fix swallowing of cancellation |
| Back | FazBrowse Home | New Git URL |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI think that the state wait_for is in right now (outside this PR) is as bad as
in swallowing a KeyboardInterrupt in a utility function. It makes it unusable
in my opinion. There is also no way for user code to counteract, whereas the
resource leakage could actually be worked around.
This leads me to possibility 1 how I think this issue could be solved:
Merge this PR, embrace the quirk and document it well.
Tell the user something along the lines of
Or alternatively:
After all, if the wrapped future yields multiple times to the event loop, you don't get any guarantees as to how far your inner future got. So the user has to be prepared to clean-up the cancellation mess one or the other way.
Possibility 2 I see is to not dismiss, but to defer the cancellation:
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityTo amend to that: this is the issue that I thinks needs a quick resolution (using pytest here, but it should get the point across):
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.