Skip to main content

Client for Debug Adapter Protocol

Project description

DAP Client: Debug Adapter Protocol Client for Python

DAP Client is an up-to-date generic client side implementation of the Debug Adapter Protocol (DAP) that is used in IDEs, editors and other tools to communicate with different debuggers. The client is not tied to any specific debugger, so it can be used to interact with any debug adapter that implements the DAP protocol, significantly reducing the effort required to build a new debugging tool. For a list of supported debug adapters, see the official specification.

Key Features

  • Sans I/O Implementation: A protocol-only client that can be integrated into any I/O framework.
  • Abstract Clients: Ready-to-use threaded and asyncio clients for immediate integration.
  • Flexible Architecture: Easily extensible to support various debugging scenarios.

Table of Contents

  1. Installation
  2. Quick Start
  3. Usage Examples
  4. API Reference
  5. License

Installation

Install DAP Client using pip:

pip install dap-client

Quick Start

The following example demonstrates how to use the async client to connect to a debugpy debug adapter server that is running on port 1234.

python -m debugpy --listen localhost:1234 --wait-for-client hello.py
import asyncio
from dap import AsyncServer

async def main():
    server = AsyncServer("debugpy", port=1234)
    try:
        await server.start()
    except asyncio.CancelledError:
        await server.stop()

if __name__ == "__main__":
    asyncio.run(main())

Usage Examples

Using the Sans I/O Client

The sans I/O client allows you to implement your own I/O mechanism:

from dap import Client
from dap.responses import Initialized

client = Client()
client.launch(no_debug=True)

# get the request data
request = client.send()

# send the request using your I/O implementation
# ...

# feed the response data to the client
for result in client.receive(response_data):
    if isinstance(result, Initialized):
        print("The debug adapter is initialized.")
    ...

Using the Threaded Socket IO Client

The threaded client provides a simple interface for synchronous usage:

from dap import ThreadedServer

server = ThreadedServer("debugpy", port=1234)
server.start()
client = server.client

# Use the client synchronously
client.launch()
client.disconnect()
server.stop()

Using the Asyncio Client

The asyncio client offers an asynchronous interface:

import asyncio
from dap import AsyncServer

async def debug_session():
    server = AsyncServer("debugpy", port=1234)
    server.start()
    client = server.client

    client.launch()
    client.disconnect()
    server.stop()

asyncio.run(debug_session())

License

DAP Client is released under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dap_python-0.5.0.tar.gz (26.2 kB view details)

Uploaded Source

Built Distribution

dap_python-0.5.0-py3-none-any.whl (29.3 kB view details)

Uploaded Python 3

File details

Details for the file dap_python-0.5.0.tar.gz.

File metadata

  • Download URL: dap_python-0.5.0.tar.gz
  • Upload date:
  • Size: 26.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.1 Windows/11

File hashes

Hashes for dap_python-0.5.0.tar.gz
Algorithm Hash digest
SHA256 a5ca44a524a61c989b2c95168f4c2473726effbb58eaf2e66232eed92aab90e8
MD5 a531edf7db58140fe6f35af0ba096b28
BLAKE2b-256 91bbe65364b35fcfc2f37cf28e85588e6c57a5b72236d198af55c0a8780fd66f

See more details on using hashes here.

File details

Details for the file dap_python-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: dap_python-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 29.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.1 Windows/11

File hashes

Hashes for dap_python-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a26fd63fb666d2069c8fc802f1e93e3fadcc2726549896b63a74544bec506d1e
MD5 48af1567f2435d73631165d6f3eac995
BLAKE2b-256 f7ac062e0083bcf114805dff22df31530a985c66955e7939ccdda95bcc102658

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page