8000 gh-96471: Add queue shutdown by EpicWink · Pull Request #96474 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-96471: Add queue shutdown #96474

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 14 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Replace try-catch with assert-raises ctx-mgrs
  • Loading branch information
EpicWink committed Feb 21, 2023
commit 978b8d1295d74026f3a50a7db8a4852927d14ce1
28 changes: 12 additions & 16 deletions Lib/test/_test_multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1281,37 +1281,33 @@ def test_closed_queue_put_get_exceptions(self):
def test_shutdown_empty(self):
q = multiprocessing.Queue()
q.shutdown()
try:
with self.assertRaises(
pyqueue.ShutDown, msg="Didn't appear to shut-down queue"
):
q.put("data")
self.fail("Didn't appear to shut-down queue")
except pyqueue.ShutDown:
pass
try:
with self.assertRaises(
pyqueue.ShutDown, msg="Didn't appear to shut-down queue"
):
q.get()
self.fail("Didn't appear to shut-down queue")
except pyqueue.ShutDown:
pass

def test_shutdown_nonempty(self):
q = multiprocessing.Queue()
q.put("data")
q.shutdown()
q.get()
try:
with self.assertRaises(
pyqueue.ShutDown, msg="Didn't appear to shut-down queue"
):
q.get()
self.fail("Didn't appear to shut-down queue")
except pyqueue.ShutDown:
pass

def test_shutdown_immediate(self):
q = multiprocessing.Queue()
q.put("data")
q.shutdown(immediate=True)
try:
with self.assertRaises(
pyqueue.ShutDown, msg="Didn't appear to shut-down queue"
):
q.get()
self.fail("Didn't appear to shut-down queue")
except pyqueue.ShutDown:
pass
#
#
#
Expand Down
0