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

Method test_fd_transfer

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

Source from the content-addressed store, hash-verified

3855 @warnings_helper.ignore_fork_in_thread_deprecation_warnings()
3856 @unittest.skipUnless(HAS_REDUCTION, "test needs multiprocessing.reduction")
3857 def test_fd_transfer(self):
3858 if self.TYPE != 'processes':
3859 self.skipTest("only makes sense with processes")
3860 conn, child_conn = self.Pipe(duplex=True)
3861
3862 p = self.Process(target=self._writefd, args=(child_conn, b"foo"))
3863 p.daemon = True
3864 p.start()
3865 self.addCleanup(os_helper.unlink, os_helper.TESTFN)
3866 with open(os_helper.TESTFN, "wb") as f:
3867 fd = f.fileno()
3868 if msvcrt:
3869 fd = msvcrt.get_osfhandle(fd)
3870 reduction.send_handle(conn, fd, p.pid)
3871 p.join()
3872 with open(os_helper.TESTFN, "rb") as f:
3873 self.assertEqual(f.read(), b"foo")
3874
3875 @warnings_helper.ignore_fork_in_thread_deprecation_warnings()
3876 @unittest.skipUnless(HAS_REDUCTION, "test needs multiprocessing.reduction")

Callers

nothing calls this directly

Calls 10

skipTestMethod · 0.80
PipeMethod · 0.80
addCleanupMethod · 0.80
openFunction · 0.50
ProcessMethod · 0.45
startMethod · 0.45
filenoMethod · 0.45
joinMethod · 0.45
assertEqualMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected