MCPcopy Index your code
hub / github.com/python/cpython / test_close

Method test_close

Lib/test/_test_multiprocessing.py:760–790  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

758
759 @warnings_helper.ignore_fork_in_thread_deprecation_warnings()
760 def test_close(self):
761 if self.TYPE == "threads":
762 self.skipTest('test not appropriate for {}'.format(self.TYPE))
763 q = self.Queue()
764 p = self.Process(target=self._test_close, kwargs={'q': q})
765 p.daemon = True
766 p.start()
767 self.assertEqual(p.is_alive(), True)
768 # Child is still alive, cannot close
769 with self.assertRaises(ValueError):
770 p.close()
771
772 q.put(None)
773 p.join()
774 self.assertEqual(p.is_alive(), False)
775 self.assertEqual(p.exitcode, 0)
776 p.close()
777 with self.assertRaises(ValueError):
778 p.is_alive()
779 with self.assertRaises(ValueError):
780 p.join()
781 with self.assertRaises(ValueError):
782 p.terminate()
783 p.close()
784
785 wr = weakref.ref(p)
786 del p
787 gc.collect()
788 self.assertIs(wr(), None)
789
790 close_queue(q)
791
792 @warnings_helper.ignore_fork_in_thread_deprecation_warnings()
793 @support.requires_resource('walltime')

Callers

nothing calls this directly

Calls 15

putMethod · 0.95
terminateMethod · 0.95
close_queueFunction · 0.85
skipTestMethod · 0.80
QueueMethod · 0.80
formatMethod · 0.45
ProcessMethod · 0.45
startMethod · 0.45
assertEqualMethod · 0.45
is_aliveMethod · 0.45
assertRaisesMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected