def main(): original_argv = list(sys.argv) try: parse_argv() except Exception as exc: print(HELP + "\nError: " + str(exc), file=sys.stderr) sys.exit(2) if options.log_to is not None: debugpy.log_to(options.log_to) if options.log_to_stderr: debugpy.log_to(sys.stderr) api.ensure_logging() log.info( "sys.argv before parsing: {0!r}\n" " after parsing: {1!r}", original_argv, sys.argv, ) try: run = { "file": run_file, "module": run_module, "code": run_code, "pid": attach_to_pid, }[options.target_kind] run() except SystemExit as exc: log.reraise_exception("Debuggee exited via SystemExit: {0!r}", exc.code, level="debug")
def start_debug_server(): if settings.LOGGING: tmp_path = tempfile.gettempdir() debugpy.log_to(tmp_path) print(f"[IDACode] Logging to {tmp_path} with pattern debugpy.*.log") debugpy.listen((settings.HOST, settings.DEBUG_PORT)) print( f"[IDACode] IDACode debug server listening on {settings.HOST}:{settings.DEBUG_PORT}" )
def start_debug_server(): if settings.LOGGING: tmp_path = tempfile.gettempdir() debugpy.log_to(tmp_path) print("[IDACode] Logging to {} with pattern debugpy.*.log".format( tmp_path)) debugpy.listen((settings.HOST, settings.DEBUG_PORT)) print( "[IDACode] IDACode debug server listening on {address}:{port}".format( address=settings.HOST, port=settings.DEBUG_PORT))
def debug(self): if Config.configured: log.debug('udebug can be configured only once') return Config.configured = True debugpy.log_to(Config.logto) # in vs code debuger select attach, port = 5678 # commands in shell: # py:debug-start debugpy.listen((Config.host, Config.port)) debugpy.wait_for_client()
def debug(self): if Config.configured: log.debug('udebug can be configured only once') return if not Config.configured: Config.configured = True debugpy.log_to(Config.logto) # in vs code debuger select attach, port = 5678 # commands in shell: # py:debug # elsewhere in python code: # import debugpy # debugpy.breakpoint() debugpy.listen((Config.host, Config.port)) debugpy.wait_for_client()
def attach(setup): log = None try: import sys if "threading" not in sys.modules: try: def on_warn(msg): print(msg, file=sys.stderr) def on_exception(msg): print(msg, file=sys.stderr) def on_critical(msg): print(msg, file=sys.stderr) pydevd_attach_to_process_path = os.path.join( _debugpy_dir, "debugpy", "_vendored", "pydevd", "pydevd_attach_to_process", ) assert os.path.exists(pydevd_attach_to_process_path) sys.path.insert(0, pydevd_attach_to_process_path) # NOTE: that it's not a part of the pydevd PYTHONPATH import attach_script attach_script.fix_main_thread_id(on_warn=on_warn, on_exception=on_exception, on_critical=on_critical) # NOTE: At this point it should be safe to remove this. sys.path.remove(pydevd_attach_to_process_path) except: import traceback traceback.print_exc() raise sys.path.insert(0, _debugpy_dir) try: import debugpy import debugpy.server from debugpy.common import log import pydevd finally: assert sys.path[0] == _debugpy_dir del sys.path[0] py_db = pydevd.get_global_debugger() if py_db is not None: py_db.dispose_and_kill_all_pydevd_threads(wait=False) if setup["log_to"] is not None: debugpy.log_to(setup["log_to"]) log.info("Configuring injected debugpy: {0!j}", setup) if setup["mode"] == "listen": debugpy.listen(setup["address"]) elif setup["mode"] == "connect": debugpy.connect(setup["address"], access_token=setup["adapter_access_token"]) else: raise AssertionError(repr(setup)) except: import traceback traceback.print_exc() if log is None: raise else: log.reraise_exception() log.info("debugpy injected successfully")
msg = '%s is running' % self.name print(msg) def create_threads(): for i in range(5): name = 'Thread #%s' % (i + 1) my_thread = Thrd(name) #my_thread.start() port = 'com4' def getbyte(): print('getbyte func') return 0 debugpy.log_to('/usr/src/PyApp1/PyApp1/') getbyte() print('start: ' + __name__) print('file:' + __file__) print(pydevd_file_utils.__file__) if __name__ == '__main__': create_threads() print('THe end')