aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Lib/multiprocessing/queues.py
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.com>2024-02-12 07:53:52 +0300
committerDaniil Cherednik <dcherednik@ydb.tech>2024-02-14 14:26:16 +0000
commit31f2a419764a8ba77c2a970cfc80056c6cd06756 (patch)
treec1995d239eba8571cefc640f6648e1d5dd4ce9e2 /contrib/tools/python3/src/Lib/multiprocessing/queues.py
parentfe2ef02b38d9c85d80060963b265a1df9f38c3bb (diff)
downloadydb-31f2a419764a8ba77c2a970cfc80056c6cd06756.tar.gz
Update Python from 3.11.8 to 3.12.2
Diffstat (limited to 'contrib/tools/python3/src/Lib/multiprocessing/queues.py')
-rw-r--r--contrib/tools/python3/src/Lib/multiprocessing/queues.py32
1 files changed, 27 insertions, 5 deletions
diff --git a/contrib/tools/python3/src/Lib/multiprocessing/queues.py b/contrib/tools/python3/src/Lib/multiprocessing/queues.py
index f37f114a96..852ae87b27 100644
--- a/contrib/tools/python3/src/Lib/multiprocessing/queues.py
+++ b/contrib/tools/python3/src/Lib/multiprocessing/queues.py
@@ -158,6 +158,20 @@ class Queue(object):
except AttributeError:
pass
+ def _terminate_broken(self):
+ # Close a Queue on error.
+
+ # gh-94777: Prevent queue writing to a pipe which is no longer read.
+ self._reader.close()
+
+ # gh-107219: Close the connection writer which can unblock
+ # Queue._feed() if it was stuck in send_bytes().
+ if sys.platform == 'win32':
+ self._writer.close()
+
+ self.close()
+ self.join_thread()
+
def _start_thread(self):
debug('Queue._start_thread()')
@@ -169,13 +183,19 @@ class Queue(object):
self._wlock, self._reader.close, self._writer.close,
self._ignore_epipe, self._on_queue_feeder_error,
self._sem),
- name='QueueFeederThread'
+ name='QueueFeederThread',
+ daemon=True,
)
- self._thread.daemon = True
- debug('doing self._thread.start()')
- self._thread.start()
- debug('... done self._thread.start()')
+ try:
+ debug('doing self._thread.start()')
+ self._thread.start()
+ debug('... done self._thread.start()')
+ except:
+ # gh-109047: During Python finalization, creating a thread
+ # can fail with RuntimeError.
+ self._thread = None
+ raise
if not self._joincancelled:
self._jointhread = Finalize(
@@ -280,6 +300,8 @@ class Queue(object):
import traceback
traceback.print_exc()
+ __class_getitem__ = classmethod(types.GenericAlias)
+
_sentinel = object()