Skip to content

bpo-26762: test_multiprocessing close more queues #2855

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

Merged
merged 1 commit into from
Jul 25, 2017
Merged
Changes from all commits
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
18 changes: 15 additions & 3 deletions Lib/test/_test_multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ def test_process(self):
self.assertEqual(p.exitcode, 0)
self.assertEqual(p.is_alive(), False)
self.assertNotIn(p, self.active_children())
close_queue(q)

@classmethod
def _sleep_some(cls):
Expand Down Expand Up @@ -461,6 +462,8 @@ def test_close(self):
gc.collect()
self.assertIs(wr(), None)

close_queue(q)

def test_many_processes(self):
if self.TYPE == 'threads':
self.skipTest('test not appropriate for {}'.format(self.TYPE))
Expand Down Expand Up @@ -501,6 +504,7 @@ def test_lose_target_ref(self):
p.join()
self.assertIs(wr(), None)
self.assertEqual(q.get(), 5)
close_queue(q)

@classmethod
def _test_child_fd_inflation(self, evt, q):
Expand Down Expand Up @@ -536,6 +540,7 @@ def test_child_fd_inflation(self):
evt.set()
for p in procs:
p.join()
close_queue(q)

#
#
Expand Down Expand Up @@ -721,6 +726,7 @@ def test_put(self):
self.assertEqual(queue_full(queue, MAXSIZE), False)

proc.join()
close_queue(queue)

@classmethod
def _test_get(cls, queue, child_can_start, parent_can_continue):
Expand Down Expand Up @@ -783,6 +789,7 @@ def test_get(self):
self.assertTimingAlmostEqual(get.elapsed, TIMEOUT3)

proc.join()
close_queue(queue)

@classmethod
def _test_fork(cls, queue):
Expand Down Expand Up @@ -818,6 +825,7 @@ def test_fork(self):
self.assertRaises(pyqueue.Empty, queue.get, False)

p.join()
close_queue(queue)

def test_qsize(self):
q = self.Queue()
Expand Down Expand Up @@ -861,6 +869,7 @@ def test_task_done(self):

for p in workers:
p.join()
close_queue(queue)

def test_no_import_lock_contention(self):
with test.support.temp_cwd():
Expand Down Expand Up @@ -891,6 +900,7 @@ def test_timeout(self):
# Tolerate a delta of 30 ms because of the bad clock resolution on
# Windows (usually 15.6 ms)
self.assertGreaterEqual(delta, 0.170)
close_queue(q)

def test_queue_feeder_donot_stop_onexc(self):
# bpo-30414: verify feeder handles exceptions correctly
Expand Down Expand Up @@ -1503,6 +1513,7 @@ def test_wait_return(self):
self.run_threads(self._test_wait_return_f, (self.barrier, queue))
results = [queue.get() for i in range(self.N)]
self.assertEqual(results.count(0), 1)
close_queue(queue)

@classmethod
def _test_action_f(cls, barrier, results):
Expand Down Expand Up @@ -3158,6 +3169,8 @@ def test_access(self):
w.close()
self.assertEqual(conn.recv(), 'foobar'*2)

p.join()

#
#
#
Expand Down Expand Up @@ -3654,7 +3667,7 @@ def _this_sub_process(q):
except pyqueue.Empty:
pass

def _test_process(q):
def _test_process():
queue = multiprocessing.Queue()
subProc = multiprocessing.Process(target=_this_sub_process, args=(queue,))
subProc.daemon = True
Expand Down Expand Up @@ -3694,8 +3707,7 @@ def flush(self):
class TestStdinBadfiledescriptor(unittest.TestCase):

def test_queue_in_process(self):
queue = multiprocessing.Queue()
proc = multiprocessing.Process(target=_test_process, args=(queue,))
proc = multiprocessing.Process(target=_test_process)
proc.start()
proc.join()

Expand Down