GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||
GeezerVison is showing github.com — API Reference API Reference
Rich Chiodo edited this page
Consider the following script: print('Hello World') First, let's import import debugpy debugpy.listen(5678) # listen for incoming DAP client connections on 127.0.0.1:5678 print('Hello World') The code above does that, but it will not block execution until a DAP client is attached - the script just continues running. If you run it, by the time you attach using your IDE of choice, it will probably already finish and exit - thus, if a breakpoint is set on import debugpy debugpy.listen(("localhost", 5678)) # listen for incoming DAP client connections debugpy.wait_for_client() # wait for a client to connect print('Hello World') List ordered by most frequently used to lest frequently used. Tells the debug server to connect to a DAP client that is accepting connections on the specified address. In Visual Studio Code, this corresponds to a
debugpy.connect(5678) debugpy.connect(('localhost', 5678)) Tells the debug server to listen for incoming DAP client connections on the specified network interface and port. In Visual Studio Code, this corresponds to a
Returns a debugpy.listen(5678) debugpy.listen(('localhost', 5678)) # See how to secure this option if you are using it with remote. debugpy.listen(('0.0.0.0', 5678)) # if you don't want to select the port yourself _, port = debugpy.listen(0) host, port = debugpy.listen(('localhost', 0)) Blocks execution of your code until a client connects to this debug server. If a client is already connected, the function returns immediately. While this function is waiting, it can be canceled by calling debugpy.wait_for_client() To cancel, you will have to invoke debugpy.wait_for_client.cancel() Makes the debugger aware of the current thread, and start tracing it. Must be called on any background thread that is started by means other than the usual Python APIs (i.e. the debugpy.debug_this_thread() import debugpy def foo(x): debugpy.debug_this_thread() print('set breakpoint here') return 0 from ctypes import CFUNCTYPE, c_void_p, c_size_t, c_uint32, windll event = threading.Event() thread_func_p = CFUNCTYPE(c_uint32, c_void_p) thread_func = thread_func_p(foo) assert windll.kernel32.CreateThread(c_void_p(0), c_size_t(0), thread_func, c_void_p(0), c_uint32(0), c_void_p(0)) event.wait() Returns immediately if no DAP client is connected to this debug server. If a client is connected, then it simulates a breakpoint on the next line. On Python 3.7 and above, this is the same as debugpy.breakpoint() print('debugger stops here') import debugpy def foo(): debugpy.breakpoint() print('here') # Debugger stops here debugpy.breakpoint() # Debugger won't stop since there is no next line in this block foo() Sets a directory to write detailed
debugpy.log_to("/tmp/logs") Tells the debug adapter to enable or disable tracing on the current thread. When the thread is traced, the debug adapter can detect breakpoints being hit, but execution is slower, especially in functions that have any breakpoints set in them. Disabling tracing when breakpoints are not anticipated to be hit can improve performance. It can also be used to skip breakpoints on a particular thread. Tracing is automatically disabled for all threads when there is no client connected to the debug adapter.
debugpy.trace_this_thread(True) import debugpy def foo(): debugpy.trace_this_thread(True) # Some performance intensive operation. debugpy.trace_this_thread(False) foo() Sets a debug property that must be known to the debug server before the client connects. Such properties can be used directly in "launch" configurations, because in that case the debuggee process after the configuration is passed. But for "attach" configurations, the process can run for a long time before it receives the debug configuration from an attaching client, and thus a different mechanism must be used to set the property values. Currently, the only property like that is This function must be called before calling debugpy.configure({"property": value, ...}) debugpy.configure(property=value, ...) If you don't want the debug server to automatically inject itself into subprocesses spawned by the process you're attaching to, specify it like so: debugpy.configure(subProcess=False) debugpy.listen(...) This is the "attach" equivalent to the following "launch" debug configuration: { "subProcess": false } Clone this wiki locally | ||||||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |