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

Method test_fork

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

Source from the content-addressed store, hash-verified

1329
1330 @warnings_helper.ignore_fork_in_thread_deprecation_warnings()
1331 def test_fork(self):
1332 # Old versions of Queue would fail to create a new feeder
1333 # thread for a forked process if the original process had its
1334 # own feeder thread. This test checks that this no longer
1335 # happens.
1336
1337 queue = self.Queue()
1338
1339 # put items on queue so that main process starts a feeder thread
1340 for i in range(10):
1341 queue.put(i)
1342
1343 # wait to make sure thread starts before we fork a new process
1344 time.sleep(DELTA)
1345
1346 # fork process
1347 p = self.Process(target=self._test_fork, args=(queue,))
1348 p.daemon = True
1349 p.start()
1350
1351 # check that all expected items are in the queue
1352 for i in range(20):
1353 self.assertEqual(queue.get(), i)
1354 self.assertRaises(pyqueue.Empty, queue.get, False)
1355
1356 p.join()
1357 close_queue(queue)
1358
1359 def test_qsize(self):
1360 q = self.Queue()

Callers

nothing calls this directly

Calls 10

putMethod · 0.95
getMethod · 0.95
close_queueFunction · 0.85
QueueMethod · 0.80
sleepMethod · 0.45
ProcessMethod · 0.45
startMethod · 0.45
assertEqualMethod · 0.45
assertRaisesMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected