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/multiprocessing/queues.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/multiprocessing/queues.py')
-rw-r--r-- | contrib/tools/python3/src/Lib/multiprocessing/queues.py | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/contrib/tools/python3/src/Lib/multiprocessing/queues.py b/contrib/tools/python3/src/Lib/multiprocessing/queues.py index 1646d270ec..a290181487 100644 --- a/contrib/tools/python3/src/Lib/multiprocessing/queues.py +++ b/contrib/tools/python3/src/Lib/multiprocessing/queues.py @@ -14,7 +14,7 @@ import os import threading import collections import time -import types +import types import weakref import errno @@ -49,7 +49,7 @@ class Queue(object): self._sem = ctx.BoundedSemaphore(maxsize) # For use by concurrent.futures self._ignore_epipe = False - self._reset() + self._reset() if sys.platform != 'win32': register_after_fork(self, Queue._after_fork) @@ -62,17 +62,17 @@ class Queue(object): def __setstate__(self, state): (self._ignore_epipe, self._maxsize, self._reader, self._writer, self._rlock, self._wlock, self._sem, self._opid) = state - self._reset() + self._reset() def _after_fork(self): debug('Queue._after_fork()') - self._reset(after_fork=True) - - def _reset(self, after_fork=False): - if after_fork: - self._notempty._at_fork_reinit() - else: - self._notempty = threading.Condition(threading.Lock()) + self._reset(after_fork=True) + + def _reset(self, after_fork=False): + if after_fork: + self._notempty._at_fork_reinit() + else: + self._notempty = threading.Condition(threading.Lock()) self._buffer = collections.deque() self._thread = None self._jointhread = None @@ -84,8 +84,8 @@ class Queue(object): self._poll = self._reader.poll def put(self, obj, block=True, timeout=None): - if self._closed: - raise ValueError(f"Queue {self!r} is closed") + if self._closed: + raise ValueError(f"Queue {self!r} is closed") if not self._sem.acquire(block, timeout): raise Full @@ -96,8 +96,8 @@ class Queue(object): self._notempty.notify() def get(self, block=True, timeout=None): - if self._closed: - raise ValueError(f"Queue {self!r} is closed") + if self._closed: + raise ValueError(f"Queue {self!r} is closed") if block and timeout is None: with self._rlock: res = self._recv_bytes() @@ -307,8 +307,8 @@ class JoinableQueue(Queue): self._cond, self._unfinished_tasks = state[-2:] def put(self, obj, block=True, timeout=None): - if self._closed: - raise ValueError(f"Queue {self!r} is closed") + if self._closed: + raise ValueError(f"Queue {self!r} is closed") if not self._sem.acquire(block, timeout): raise Full @@ -346,10 +346,10 @@ class SimpleQueue(object): else: self._wlock = ctx.Lock() - def close(self): - self._reader.close() - self._writer.close() - + def close(self): + self._reader.close() + self._writer.close() + def empty(self): return not self._poll() @@ -376,5 +376,5 @@ class SimpleQueue(object): else: with self._wlock: self._writer.send_bytes(obj) - - __class_getitem__ = classmethod(types.GenericAlias) + + __class_getitem__ = classmethod(types.GenericAlias) |