summaryrefslogtreecommitdiff
path: root/Lib/asyncio/locks.py
diff options
context:
space:
mode:
authorAndrew Svetlov <andrew.svetlov@gmail.com>2019-05-16 17:52:10 +0300
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-05-16 07:52:10 -0700
commit68b34a720485f399e8699235b8f4e08f227dd43b (patch)
tree49bbe28097e67a4ffbf9c39d9b5b143c5cbe607d /Lib/asyncio/locks.py
parentdbacfc227381fbc7b3c886ea0bd7806ab3dc62c2 (diff)
downloadcpython-git-68b34a720485f399e8699235b8f4e08f227dd43b.tar.gz
bpo-36921: Deprecate @coroutine for sake of async def (GH-13346)
The second attempt. Now deprecate `@coroutine` only, keep `yield from fut` as is. https://bugs.python.org/issue36921
Diffstat (limited to 'Lib/asyncio/locks.py')
-rw-r--r--Lib/asyncio/locks.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/asyncio/locks.py b/Lib/asyncio/locks.py
index 639bd11bd0..d59eb8f210 100644
--- a/Lib/asyncio/locks.py
+++ b/Lib/asyncio/locks.py
@@ -3,12 +3,13 @@
__all__ = ('Lock', 'Event', 'Condition', 'Semaphore', 'BoundedSemaphore')
import collections
+import types
import warnings
from . import events
from . import futures
from . import exceptions
-from .coroutines import coroutine
+from .import coroutines
class _ContextManager:
@@ -55,7 +56,7 @@ class _ContextManagerMixin:
# always raises; that's how the with-statement works.
pass
- @coroutine
+ @types.coroutine
def __iter__(self):
# This is not a coroutine. It is meant to enable the idiom:
#
@@ -78,6 +79,9 @@ class _ContextManagerMixin:
yield from self.acquire()
return _ContextManager(self)
+ # The flag is needed for legacy asyncio.iscoroutine()
+ __iter__._is_coroutine = coroutines._is_coroutine
+
async def __acquire_ctx(self):
await self.acquire()
return _ContextManager(self)