mirror of
https://github.com/python/cpython.git
synced 2025-10-27 19:54:38 +00:00
asyncio: sync with Tulip, add a new asyncio.coroutines module
This commit is contained in:
parent
61f32cb5b8
commit
f951d28ac8
12 changed files with 221 additions and 199 deletions
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
from . import events
|
||||
from . import futures
|
||||
from . import tasks
|
||||
from .coroutines import coroutine
|
||||
|
||||
|
||||
class _ContextManager:
|
||||
|
|
@ -112,7 +112,7 @@ def locked(self):
|
|||
"""Return True if lock is acquired."""
|
||||
return self._locked
|
||||
|
||||
@tasks.coroutine
|
||||
@coroutine
|
||||
def acquire(self):
|
||||
"""Acquire a lock.
|
||||
|
||||
|
|
@ -225,7 +225,7 @@ def clear(self):
|
|||
to true again."""
|
||||
self._value = False
|
||||
|
||||
@tasks.coroutine
|
||||
@coroutine
|
||||
def wait(self):
|
||||
"""Block until the internal flag is true.
|
||||
|
||||
|
|
@ -278,7 +278,7 @@ def __repr__(self):
|
|||
extra = '{},waiters:{}'.format(extra, len(self._waiters))
|
||||
return '<{} [{}]>'.format(res[1:-1], extra)
|
||||
|
||||
@tasks.coroutine
|
||||
@coroutine
|
||||
def wait(self):
|
||||
"""Wait until notified.
|
||||
|
||||
|
|
@ -306,7 +306,7 @@ def wait(self):
|
|||
finally:
|
||||
yield from self.acquire()
|
||||
|
||||
@tasks.coroutine
|
||||
@coroutine
|
||||
def wait_for(self, predicate):
|
||||
"""Wait until a predicate becomes true.
|
||||
|
||||
|
|
@ -402,7 +402,7 @@ def locked(self):
|
|||
"""Returns True if semaphore can not be acquired immediately."""
|
||||
return self._value == 0
|
||||
|
||||
@tasks.coroutine
|
||||
@coroutine
|
||||
def acquire(self):
|
||||
"""Acquire a semaphore.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue