diff options
Diffstat (limited to 'Lib/asyncio/locks.py')
-rw-r--r-- | Lib/asyncio/locks.py | 8 |
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) |