(level)
| 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 |
nothing calls this directly
no test coverage detected