Skip to content
New issue

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

bpo-38599: Deprecate creation of asyncio object when the loop is not running #18195

Open
wants to merge 2 commits into
base: master
from

Conversation

@eamanu
Copy link
Contributor

eamanu commented Jan 26, 2020

Add Deprecation Warning when Queue and Locks are created and
the loop is not running.

https://bugs.python.org/issue38599

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)
Comment on lines +171 to +175

This comment has been minimized.

Copy link
@aeros

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)

@aeros

This comment has been minimized.

Copy link
Member

aeros commented Jan 27, 2020

I believe this change should also be implemented for the other synchronization primitives: asyncio.Event, asyncio.Condition, asyncio.Semaphore, and asyncio.BoundedSemaphore.

@eamanu

This comment has been minimized.

Copy link
Contributor Author

eamanu commented Jan 27, 2020

@aeros thanks for the review, I will fix the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.