()
| 931 | |
| 932 | def create_fork(original_name): |
| 933 | def new_fork(): |
| 934 | # A simple fork will result in a new python process |
| 935 | is_new_python_process = True |
| 936 | frame = sys._getframe() |
| 937 | |
| 938 | apply_arg_patch = _get_apply_arg_patching() |
| 939 | |
| 940 | is_subprocess_fork = False |
| 941 | while frame is not None: |
| 942 | if frame.f_code.co_name == "_execute_child" and "subprocess" in frame.f_code.co_filename: |
| 943 | is_subprocess_fork = True |
| 944 | # If we're actually in subprocess.Popen creating a child, it may |
| 945 | # result in something which is not a Python process, (so, we |
| 946 | # don't want to connect with it in the forked version). |
| 947 | executable = frame.f_locals.get("executable") |
| 948 | if executable is not None: |
| 949 | is_new_python_process = False |
| 950 | if is_python(executable): |
| 951 | is_new_python_process = True |
| 952 | break |
| 953 | |
| 954 | frame = frame.f_back |
| 955 | frame = None # Just make sure we don't hold on to it. |
| 956 | |
| 957 | protocol = pydevd_constants.get_protocol() |
| 958 | debug_mode = PydevdCustomization.DEBUG_MODE |
| 959 | |
| 960 | child_process = getattr(os, original_name)() # fork |
| 961 | if not child_process: |
| 962 | if is_new_python_process: |
| 963 | PydevdCustomization.DEFAULT_PROTOCOL = protocol |
| 964 | PydevdCustomization.DEBUG_MODE = debug_mode |
| 965 | _on_forked_process(setup_tracing=apply_arg_patch and not is_subprocess_fork) |
| 966 | else: |
| 967 | set_global_debugger(None) |
| 968 | else: |
| 969 | if is_new_python_process: |
| 970 | send_process_created_message() |
| 971 | return child_process |
| 972 | |
| 973 | return new_fork |
| 974 |
nothing calls this directly
no test coverage detected