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

Method fork_with_import_lock

Lib/test/test_fork1.py:71–92  ·  view source on GitHub ↗
(level)

Source from the content-addressed store, hash-verified

69 exitcode = 42
70 # Issue 9573: this used to trigger RuntimeError in the child process
71 def fork_with_import_lock(level):
72 release = 0
73 in_child = False
74 try:
75 try:
76 for i in range(level):
77 imp.acquire_lock()
78 release += 1
79 pid = os.fork()
80 in_child = not pid
81 finally:
82 for i in range(release):
83 imp.release_lock()
84 except RuntimeError:
85 if in_child:
86 if support.verbose > 1:
87 print("RuntimeError in child")
88 os._exit(1)
89 raise
90 if in_child:
91 os._exit(exitcode)
92 self.wait_impl(pid, exitcode=exitcode)
93
94 # Check this works with various levels of nested
95 # import in the main thread

Callers

nothing calls this directly

Calls 3

acquire_lockMethod · 0.45
_exitMethod · 0.45
wait_implMethod · 0.45

Tested by

no test coverage detected