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

Method fork_thread

Lib/test/test_thread.py:424–440  ·  view source on GitHub ↗
(read_fd, write_fd)

Source from the content-addressed store, hash-verified

422 pid = None
423
424 def fork_thread(read_fd, write_fd):
425 nonlocal pid
426
427 # Ignore the warning about fork with threads.
428 with warnings.catch_warnings(category=DeprecationWarning,
429 action="ignore"):
430 # fork in a thread (DANGER, undefined per POSIX)
431 if (pid := os.fork()):
432 # parent process
433 return
434
435 # child process
436 try:
437 os.close(read_fd)
438 os.write(write_fd, b"OK")
439 finally:
440 os._exit(0)
441
442 with threading_helper.wait_threads_exit():
443 thread.start_new_thread(fork_thread, (self.read_fd, self.write_fd))

Callers

nothing calls this directly

Calls 3

closeMethod · 0.45
writeMethod · 0.45
_exitMethod · 0.45

Tested by

no test coverage detected