diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
commit | e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (patch) | |
tree | 64175d5cadab313b3e7039ebaa06c5bc3295e274 /contrib/tools/python3/src/Lib/asyncio/locks.py | |
parent | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (diff) | |
download | ydb-e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/tools/python3/src/Lib/asyncio/locks.py')
-rw-r--r-- | contrib/tools/python3/src/Lib/asyncio/locks.py | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/contrib/tools/python3/src/Lib/asyncio/locks.py b/contrib/tools/python3/src/Lib/asyncio/locks.py index 218226dca2..f1ce732478 100644 --- a/contrib/tools/python3/src/Lib/asyncio/locks.py +++ b/contrib/tools/python3/src/Lib/asyncio/locks.py @@ -6,7 +6,7 @@ import collections import warnings from . import events -from . import exceptions +from . import exceptions class _ContextManagerMixin: @@ -75,15 +75,15 @@ class Lock(_ContextManagerMixin): """ def __init__(self, *, loop=None): - self._waiters = None + self._waiters = None self._locked = False - if loop is None: - self._loop = events.get_event_loop() - else: + if loop is None: + self._loop = events.get_event_loop() + else: self._loop = loop - warnings.warn("The loop argument is deprecated since Python 3.8, " - "and scheduled for removal in Python 3.10.", - DeprecationWarning, stacklevel=2) + warnings.warn("The loop argument is deprecated since Python 3.8, " + "and scheduled for removal in Python 3.10.", + DeprecationWarning, stacklevel=2) def __repr__(self): res = super().__repr__() @@ -102,13 +102,13 @@ class Lock(_ContextManagerMixin): This method blocks until the lock is unlocked, then sets it to locked and returns True. """ - if (not self._locked and (self._waiters is None or - all(w.cancelled() for w in self._waiters))): + if (not self._locked and (self._waiters is None or + all(w.cancelled() for w in self._waiters))): self._locked = True return True - if self._waiters is None: - self._waiters = collections.deque() + if self._waiters is None: + self._waiters = collections.deque() fut = self._loop.create_future() self._waiters.append(fut) @@ -120,7 +120,7 @@ class Lock(_ContextManagerMixin): await fut finally: self._waiters.remove(fut) - except exceptions.CancelledError: + except exceptions.CancelledError: if not self._locked: self._wake_up_first() raise @@ -147,8 +147,8 @@ class Lock(_ContextManagerMixin): def _wake_up_first(self): """Wake up the first waiter if it isn't done.""" - if not self._waiters: - return + if not self._waiters: + return try: fut = next(iter(self._waiters)) except StopIteration: @@ -173,13 +173,13 @@ class Event: def __init__(self, *, loop=None): self._waiters = collections.deque() self._value = False - if loop is None: - self._loop = events.get_event_loop() - else: + if loop is None: + self._loop = events.get_event_loop() + else: self._loop = loop - warnings.warn("The loop argument is deprecated since Python 3.8, " - "and scheduled for removal in Python 3.10.", - DeprecationWarning, stacklevel=2) + warnings.warn("The loop argument is deprecated since Python 3.8, " + "and scheduled for removal in Python 3.10.", + DeprecationWarning, stacklevel=2) def __repr__(self): res = super().__repr__() @@ -240,16 +240,16 @@ class Condition(_ContextManagerMixin): """ def __init__(self, lock=None, *, loop=None): - if loop is None: - self._loop = events.get_event_loop() - else: + if loop is None: + self._loop = events.get_event_loop() + else: self._loop = loop - warnings.warn("The loop argument is deprecated since Python 3.8, " - "and scheduled for removal in Python 3.10.", - DeprecationWarning, stacklevel=2) + warnings.warn("The loop argument is deprecated since Python 3.8, " + "and scheduled for removal in Python 3.10.", + DeprecationWarning, stacklevel=2) if lock is None: - lock = Lock(loop=loop) + lock = Lock(loop=loop) elif lock._loop is not self._loop: raise ValueError("loop argument must agree with lock") @@ -299,11 +299,11 @@ class Condition(_ContextManagerMixin): try: await self.acquire() break - except exceptions.CancelledError: + except exceptions.CancelledError: cancelled = True if cancelled: - raise exceptions.CancelledError + raise exceptions.CancelledError async def wait_for(self, predicate): """Wait until a predicate becomes true. @@ -371,13 +371,13 @@ class Semaphore(_ContextManagerMixin): raise ValueError("Semaphore initial value must be >= 0") self._value = value self._waiters = collections.deque() - if loop is None: - self._loop = events.get_event_loop() - else: + if loop is None: + self._loop = events.get_event_loop() + else: self._loop = loop - warnings.warn("The loop argument is deprecated since Python 3.8, " - "and scheduled for removal in Python 3.10.", - DeprecationWarning, stacklevel=2) + warnings.warn("The loop argument is deprecated since Python 3.8, " + "and scheduled for removal in Python 3.10.", + DeprecationWarning, stacklevel=2) def __repr__(self): res = super().__repr__() @@ -437,11 +437,11 @@ class BoundedSemaphore(Semaphore): """ def __init__(self, value=1, *, loop=None): - if loop: - warnings.warn("The loop argument is deprecated since Python 3.8, " - "and scheduled for removal in Python 3.10.", - DeprecationWarning, stacklevel=2) - + if loop: + warnings.warn("The loop argument is deprecated since Python 3.8, " + "and scheduled for removal in Python 3.10.", + DeprecationWarning, stacklevel=2) + self._bound_value = value super().__init__(value, loop=loop) |