bpo-34728: Remove deprecate *loop* argument in asyncio.sleep#9415
bpo-34728: Remove deprecate *loop* argument in asyncio.sleep#9415willingc merged 7 commits intopython:masterfrom
Conversation
|
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA (this might be simply due to a missing "GitHub Name" entry in your b.p.o account settings). This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. You can check yourself to see if the CLA has been received. Thanks again for your contribution, we look forward to reviewing it! |
There was a problem hiding this comment.
I think that just removing the loop argument may be bad for compatibility reasons. Perhaps it is better to catch the argument and raise an DeprecationWarning, as proposed in the issue
There was a problem hiding this comment.
@fbidu very good. I will change for this and send the PR again. Thank you for your review.
a015623 to
db2c478
Compare
| self.assertEqual(result, 11) | ||
|
|
||
| def test_loop_argument_is_deprecated(self): | ||
| """ |
There was a problem hiding this comment.
Use a regular comment for this, not a docstring.
| will be removed | ||
| """ | ||
| with self.assertWarns(DeprecationWarning): | ||
| self.loop.run_until_complete(asyncio.wait_for(coroutine_function(), |
There was a problem hiding this comment.
Weird formatting, I'd do this:
self.loop.run_until_complete(
asyncio.wait_for(coroutine_function(), 0.01, loop=self.loop))
Looks like CI failures are unrelated to this PR. |
|
@1st1 Could you check again? |
|
Please add a news entry using blurb |
|
@1st1 It is my first contribution in Python. :-) |
|
@asvetlov please take a look too. @joaojunior BTW, I think we can also replace |
|
@1st1 Very good. I will change and run the tests to verify. |
willingc
left a comment
There was a problem hiding this comment.
Thanks @joaojunior for this PR. I've made some small style suggestions should you wish to add them to the PR.
| @@ -0,0 +1,2 @@ | |||
| Add warn when deprecate argument `loop` is used in methods: `asyncio.sleep`, | |||
There was a problem hiding this comment.
Perhaps a bit clearer: Add deprecation warning when loop is used ...
| self.assertEqual(result, 11) | ||
|
|
||
| def test_loop_argument_is_deprecated(self): | ||
| # this test should be removed in Python 4.0 when the loop argument |
There was a problem hiding this comment.
If possible, would you like to shorten the 2 line comment to 1 line in these tests?
Suggestion: Remove test when loop argument is removed in Python 4.0
Thanks for writing tests 😄
There was a problem hiding this comment.
Hi @willingc Thanks for your comments. I will change now.
|
@willingc Thank you for your suggestions and help. I already change. |
willingc
left a comment
There was a problem hiding this comment.
Looks good. Thanks for making the updates @joaojunior
| loop = events.get_event_loop() | ||
| loop = events.get_running_loop() | ||
| else: | ||
| warnings.warn("The loop argument is deprecated and scheduled for" |
There was a problem hiding this comment.
All of the warning messages are missing spaces (between "for" and "removal").
There was a problem hiding this comment.
You're right. @joaojunior please submit another PR to fix this.
@willingc I don't think @asvetlov had a chance to review this PR :(
|
Sorry, I have a pretty busy week. |
|
I think it's OK to leave DeprecationWarning as it's just completely non-sensical to pass the |
In this PR: python/cpython#9415 asyncio.sleep switched to requiring a running asyncio event loop. This is all very sensible, but broke our test that checks what happens when some accidentally yields an asyncio.Future to the Trio run loop. Switch the test to waiting on a Future directly.
|
I know many (old but still executed) codes that pass I don't have a strong preference but have a feeling that we need to be consistent in API deprecation. |
Warn deprecate argument loop in
asyncio.sleep,asyncio.waitandasyncio.wait_for. Also change calls forget_event_loop()to calls forget_running_loop()in these methods.https://bugs.python.org/issue34728