Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upbpo-38599: Deprecate creation of asyncio object when the loop is not running #18195
Conversation
Add Deprecation Warning when Queue and Locks are created and the loop is not running.
if not self._loop.is_running(): | ||
warnings.warn("The asyncio objects created without running " | ||
"event loop is deprecated since Python 3.9 and " | ||
"scheduled for removal in Python 3.10.", | ||
DeprecationWarning, stacklevel=2) |
This comment has been minimized.
This comment has been minimized.
aeros
Jan 27, 2020
•
Member
Thanks for the PR @eamanu.
The implementation of the warning looks fine, but the message itself could use some grammatical fixes.
Also, @1st1 @asvetlov, what do you think about the 3.10 removal version? IMO, this removal would end up breaking far too much code to be changed in the next version, and even two versions might be too early still. I think for now we should leave it as a DeprecationWarning
, and remove it later down the road when users have had plenty of time to adjust rather than having a fixed removal date. Especially considering that we'll be breaking a substantial amount of code already in 3.10, with the event loop argument removals throughout asyncio.
With the above in mind, I'd suggest changing the warning message to the following:
The creation of asyncio objects without a running
event loop is deprecated as of Python 3.9.
(This also applies to the warning message for asyncio.Queue
)
This comment has been minimized.
This comment has been minimized.
I believe this change should also be implemented for the other synchronization primitives: |
This comment has been minimized.
This comment has been minimized.
@aeros thanks for the review, I will fix the PR |
eamanu commentedJan 26, 2020
•
edited by bedevere-bot
Add Deprecation Warning when Queue and Locks are created and
the loop is not running.
https://bugs.python.org/issue38599