You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Deprecate old-style locking in asyncio/locks.py #76434
This can make harder writing portable code that works in 2.7, 3.4 and 3.7.
What is the benefit of the deprecation? Are there inevitable design or implementation errors in these constructions? Or getting rid of them can significantly simplify the implementation?
with (yield from lock) is based on very non-obvious tricks:
a) lock.enter is forbidden and raises RuntimeError
b) actually lock.iter is called for lock acquiring before calling with
c) the object returned from iter is a context manager with enter/exit methods
This can make harder writing portable code that works in 2.7, 3.4 and 3.7.
asyncio for Python 3.4 is fairly outdated. Most of the async packages today require 3.5+, as they usually use async/await syntax. I say this sort of backwards compatibility (showing a warning) isn't really a big concern. A bigger concern for us is new code using 'with await lock' pattern, hence the warning.
Activity
asvetlov commentedon Dec 8, 2017
Now constructions like
await lock # "yield from lock" can be used as well
try:
...
finally:
lock.release()
and
are supported. Let's deprecate them in favor of
serhiy-storchaka commentedon Dec 9, 2017
This can make harder writing portable code that works in 2.7, 3.4 and 3.7.
What is the benefit of the deprecation? Are there inevitable design or implementation errors in these constructions? Or getting rid of them can significantly simplify the implementation?
asvetlov commentedon Dec 9, 2017
a) lock.enter is forbidden and raises RuntimeError
b) actually lock.iter is called for lock acquiring before calling
withc) the object returned from iter is a context manager with enter/exit methods
yield fromstyle is fully supported still).1st1 commentedon Dec 9, 2017
asyncio for Python 3.4 is fairly outdated. Most of the async packages today require 3.5+, as they usually use async/await syntax. I say this sort of backwards compatibility (showing a warning) isn't really a big concern. A bigger concern for us is new code using 'with await lock' pattern, hence the warning.
asvetlov commentedon Dec 9, 2017
New changeset 28d8d14 by Andrew Svetlov in branch 'master':
bpo-32253: Deprecate with statement and bare await for asyncio locks (GH-4764)
28d8d14