def new_fork(): import pydevd host, port = pydevd.get_host_and_port() import os child_process = getattr(os, original_name)() # fork if not child_process: if port is not None: import pydevd pydevd.settrace_forked(host, port) return child_process
def patch_args(args): try: if DEBUG_TRACE_MULTIPROCESSING > 0: sys.stderr.write("Patching args: %s\n" % str(args)) new_args = [] i = 0 if len(args) == 0: return args if is_python(args[0]): try: indC = args.index('-c') except ValueError: indC = -1 if indC != -1: import pydevd host, port = pydevd.get_host_and_port() if port is not None: new_args.extend(args) new_args[indC + 1] = ("import sys; sys.path.append(r'%s'); import pydevd; " "pydevd.settrace(host='%s', port=%s, suspend=False, trace_only_current_thread=False, patch_multiprocessing=True); %s") % ( pydev_src_dir, host, port, args[indC + 1]) return new_args else: new_args.append(args[0]) else: if DEBUG_TRACE_MULTIPROCESSING > 0: sys.stderr.write("Process is not python, returning.\n") return args i = 1 while i < len(args): if args[i].startswith('-'): new_args.append(args[i]) else: break i += 1 if args[i].endswith('pydevd.py'): #no need to add pydevd twice return args for x in sys.original_argv: if sys.platform == "win32" and not x.endswith('"'): arg = '"%s"' % x else: arg = x new_args.append(arg) if x == '--file': break while i < len(args): new_args.append(args[i]) i += 1 return new_args except: traceback.print_exc() return args
def patch_args(args): try: if DEBUG_TRACE_MULTIPROCESSING > 0: sys.stderr.write("Patching args: %s\n" % str(args)) new_args = [] i = 0 if len(args) == 0: return args if is_python(args[0]): try: indC = args.index('-c') except ValueError: indC = -1 if indC != -1: import pydevd host, port = pydevd.get_host_and_port() if port is not None: new_args.extend(args) new_args[indC + 1] = ( "import sys; sys.path.append(r'%s'); import pydevd; " "pydevd.settrace(host='%s', port=%s, suspend=False, trace_only_current_thread=False, patch_multiprocessing=True); %s" ) % (pydev_src_dir, host, port, args[indC + 1]) return new_args else: new_args.append(args[0]) else: if DEBUG_TRACE_MULTIPROCESSING > 0: sys.stderr.write("Process is not python, returning.\n") return args i = 1 while i < len(args): if args[i].startswith('-'): new_args.append(args[i]) else: break i += 1 if args[i].endswith('pydevd.py'): #no need to add pydevd twice return args for x in sys.original_argv: if sys.platform == "win32" and not x.endswith('"'): arg = '"%s"' % x else: arg = x new_args.append(arg) if x == '--file': break while i < len(args): new_args.append(args[i]) i += 1 return new_args except: traceback.print_exc() return args