summaryrefslogtreecommitdiff
path: root/Lib/multiprocessing
diff options
context:
space:
mode:
authorZackery Spytz <zspytz@gmail.com>2018-10-13 03:26:09 -0600
committerSerhiy Storchaka <storchaka@gmail.com>2018-10-13 12:26:09 +0300
commit0461704060474cb358d3495322950c4fd00616a0 (patch)
treecebe84cdbb8e7c0b2ec7c01e6ffd83aabbd282a3 /Lib/multiprocessing
parente385d0661ecf8bc9ba95c4395d9a11262c2cbfec (diff)
downloadcpython-git-0461704060474cb358d3495322950c4fd00616a0.tar.gz
bpo-22872: multiprocessing.Queue's put() and get() now raise ValueError if the queue is closed. (GH-9010)
Previously, put() and get() would raise AssertionError and OSError, respectively.
Diffstat (limited to 'Lib/multiprocessing')
-rw-r--r--Lib/multiprocessing/queues.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/multiprocessing/queues.py b/Lib/multiprocessing/queues.py
index 88f7d267bf..d112db2cd9 100644
--- a/Lib/multiprocessing/queues.py
+++ b/Lib/multiprocessing/queues.py
@@ -78,7 +78,8 @@ class Queue(object):
self._poll = self._reader.poll
def put(self, obj, block=True, timeout=None):
- assert not self._closed, "Queue {0!r} has been closed".format(self)
+ if self._closed:
+ raise ValueError(f"Queue {self!r} is closed")
if not self._sem.acquire(block, timeout):
raise Full
@@ -89,6 +90,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 block and timeout is None:
with self._rlock:
res = self._recv_bytes()
@@ -298,7 +301,8 @@ class JoinableQueue(Queue):
self._cond, self._unfinished_tasks = state[-2:]
def put(self, obj, block=True, timeout=None):
- assert not self._closed, "Queue {0!r} is closed".format(self)
+ if self._closed:
+ raise ValueError(f"Queue {self!r} is closed")
if not self._sem.acquire(block, timeout):
raise Full