mirror of
https://github.com/microsoft/debugpy.git
synced 2025-12-23 08:48:12 +00:00
Purge all mentions of "IDE", and replace with "client" or "clients" as appropriate.
Blacken code.
This commit is contained in:
parent
77654f6ff6
commit
8c114ed589
15 changed files with 99 additions and 149 deletions
|
|
@ -22,7 +22,7 @@ __file__ = os.path.abspath(__file__)
|
|||
def main(args):
|
||||
from debugpy import adapter
|
||||
from debugpy.common import compat, log, sockets
|
||||
from debugpy.adapter import ide, servers, sessions
|
||||
from debugpy.adapter import clients, servers, sessions
|
||||
|
||||
if args.for_server is not None:
|
||||
if os.name == "posix":
|
||||
|
|
@ -58,15 +58,13 @@ def main(args):
|
|||
else:
|
||||
endpoints = {"server": {"host": server_host, "port": server_port}}
|
||||
try:
|
||||
ide_host, ide_port = ide.serve(args.host, args.port)
|
||||
client_host, client_port = clients.serve(args.host, args.port)
|
||||
except Exception as exc:
|
||||
if args.for_server is None:
|
||||
raise
|
||||
endpoints = {
|
||||
"error": "Can't listen for IDE connections: " + str(exc)
|
||||
}
|
||||
endpoints = {"error": "Can't listen for client connections: " + str(exc)}
|
||||
else:
|
||||
endpoints["client"] = {"host": ide_host, "port": ide_port}
|
||||
endpoints["client"] = {"host": client_host, "port": client_port}
|
||||
|
||||
if args.for_server is not None:
|
||||
log.info(
|
||||
|
|
@ -96,9 +94,7 @@ def main(args):
|
|||
|
||||
listener_file = os.getenv("DEBUGPY_ADAPTER_ENDPOINTS")
|
||||
if listener_file is not None:
|
||||
log.info(
|
||||
"Writing endpoints info to {0!r}:\n{1!j}", listener_file, endpoints
|
||||
)
|
||||
log.info("Writing endpoints info to {0!r}:\n{1!j}", listener_file, endpoints)
|
||||
|
||||
def delete_listener_file():
|
||||
log.info("Listener ports closed; deleting {0!r}", listener_file)
|
||||
|
|
@ -115,13 +111,13 @@ def main(args):
|
|||
raise log.exception("Error writing endpoints info to file:")
|
||||
|
||||
if args.port is None:
|
||||
ide.IDE("stdio")
|
||||
clients.Client("stdio")
|
||||
|
||||
# These must be registered after the one above, to ensure that the listener sockets
|
||||
# are closed before the endpoint info file is deleted - this way, another process
|
||||
# can wait for the file to go away as a signal that the ports are no longer in use.
|
||||
atexit.register(servers.stop_serving)
|
||||
atexit.register(ide.stop_serving)
|
||||
atexit.register(clients.stop_serving)
|
||||
|
||||
servers.wait_until_disconnected()
|
||||
log.info("All debug servers disconnected; waiting for remaining sessions...")
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ from debugpy.common.compat import unicode
|
|||
from debugpy.adapter import components, servers, sessions
|
||||
|
||||
|
||||
class IDE(components.Component):
|
||||
"""Handles the IDE side of a debug session."""
|
||||
class Client(components.Component):
|
||||
"""Handles the client side of a debug session."""
|
||||
|
||||
message_handler = components.Component.message_handler
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ class IDE(components.Component):
|
|||
|
||||
def __init__(self, sock):
|
||||
if sock == "stdio":
|
||||
log.info("Connecting to IDE over stdio...", self)
|
||||
log.info("Connecting to client over stdio...", self)
|
||||
stream = messaging.JsonIOStream.from_stdio()
|
||||
# Make sure that nothing else tries to interfere with the stdio streams
|
||||
# that are going to be used for DAP communication from now on.
|
||||
|
|
@ -46,22 +46,22 @@ class IDE(components.Component):
|
|||
stream = messaging.JsonIOStream.from_socket(sock)
|
||||
|
||||
with sessions.Session() as session:
|
||||
super(IDE, self).__init__(session, stream)
|
||||
super(Client, self).__init__(session, stream)
|
||||
|
||||
self.client_id = None
|
||||
"""ID of the connecting client. This can be 'test' while running tests."""
|
||||
|
||||
self.has_started = False
|
||||
"""Whether the "launch" or "attach" request was received from the IDE, and
|
||||
"""Whether the "launch" or "attach" request was received from the client, and
|
||||
fully handled.
|
||||
"""
|
||||
|
||||
self.start_request = None
|
||||
"""The "launch" or "attach" request as received from the IDE.
|
||||
"""The "launch" or "attach" request as received from the client.
|
||||
"""
|
||||
|
||||
self._initialize_request = None
|
||||
"""The "initialize" request as received from the IDE, to propagate to the
|
||||
"""The "initialize" request as received from the client, to propagate to the
|
||||
server later."""
|
||||
|
||||
self._deferred_events = []
|
||||
|
|
@ -70,11 +70,11 @@ class IDE(components.Component):
|
|||
"""
|
||||
|
||||
self._known_subprocesses = set()
|
||||
"""servers.Connection instances for subprocesses that this IDE has been
|
||||
"""servers.Connection instances for subprocesses that this client has been
|
||||
made aware of.
|
||||
"""
|
||||
|
||||
session.ide = self
|
||||
session.client = self
|
||||
session.register()
|
||||
|
||||
# For the transition period, send the telemetry events with both old and new
|
||||
|
|
@ -97,26 +97,26 @@ class IDE(components.Component):
|
|||
)
|
||||
|
||||
def propagate_after_start(self, event):
|
||||
# pydevd starts sending events as soon as we connect, but the IDE doesn't
|
||||
# pydevd starts sending events as soon as we connect, but the client doesn't
|
||||
# expect to see any until it receives the response to "launch" or "attach"
|
||||
# request. If IDE is not ready yet, save the event instead of propagating
|
||||
# request. If client is not ready yet, save the event instead of propagating
|
||||
# it immediately.
|
||||
if self._deferred_events is not None:
|
||||
self._deferred_events.append(event)
|
||||
log.debug("Propagation deferred.")
|
||||
else:
|
||||
self.ide.channel.propagate(event)
|
||||
self.client.channel.propagate(event)
|
||||
|
||||
def _propagate_deferred_events(self):
|
||||
log.debug("Propagating deferred events to {0}...", self.ide)
|
||||
log.debug("Propagating deferred events to {0}...", self.client)
|
||||
for event in self._deferred_events:
|
||||
log.debug("Propagating deferred {0}", event.describe())
|
||||
self.ide.channel.propagate(event)
|
||||
log.info("All deferred events propagated to {0}.", self.ide)
|
||||
self.client.channel.propagate(event)
|
||||
log.info("All deferred events propagated to {0}.", self.client)
|
||||
self._deferred_events = None
|
||||
|
||||
# Generic event handler. There are no specific handlers for IDE events, because
|
||||
# there are no events from the IDE in DAP - but we propagate them if we can, in
|
||||
# Generic event handler. There are no specific handlers for client events, because
|
||||
# there are no events from the client in DAP - but we propagate them if we can, in
|
||||
# case some events appear in future protocol versions.
|
||||
@message_handler
|
||||
def event(self, event):
|
||||
|
|
@ -166,7 +166,6 @@ class IDE(components.Component):
|
|||
# See https://github.com/microsoft/vscode/issues/4902#issuecomment-368583522
|
||||
# for the sequence of request and events necessary to orchestrate the start.
|
||||
def _start_message_handler(f):
|
||||
|
||||
@components.Component.message_handler
|
||||
def handle(self, request):
|
||||
assert request.is_request("launch", "attach")
|
||||
|
|
@ -195,7 +194,9 @@ class IDE(components.Component):
|
|||
# The launcher is doing output redirection, so we don't need the
|
||||
# server to do it, as well.
|
||||
arguments = dict(arguments)
|
||||
arguments["debugOptions"] = list(debug_options - {"RedirectOutput"})
|
||||
arguments["debugOptions"] = list(
|
||||
debug_options - {"RedirectOutput"}
|
||||
)
|
||||
|
||||
if arguments.get("redirectOutput"):
|
||||
arguments = dict(arguments)
|
||||
|
|
@ -232,7 +233,7 @@ class IDE(components.Component):
|
|||
},
|
||||
)
|
||||
|
||||
# Let the IDE know that it can begin configuring the adapter.
|
||||
# Let the client know that it can begin configuring the adapter.
|
||||
self.channel.send_event("initialized")
|
||||
|
||||
self.start_request = request
|
||||
|
|
@ -310,12 +311,12 @@ class IDE(components.Component):
|
|||
#
|
||||
# If neither is specified, and "waitForAttach" is false, this is attach-by-socket
|
||||
# in which the server has spawned the adapter via debugpy.listen(). There
|
||||
# is no PID known to the IDE in advance, but the server connection should be
|
||||
# is no PID known to the client in advance, but the server connection should be
|
||||
# either be there already, or the server should be connecting shortly, so there
|
||||
# must be a timeout.
|
||||
#
|
||||
# In the last two cases, if there's more than one server connection already,
|
||||
# this is a multiprocess re-attach. The IDE doesn't know the PID, so we just
|
||||
# this is a multiprocess re-attach. The client doesn't know the PID, so we just
|
||||
# connect it to the oldest server connection that we have - in most cases, it
|
||||
# will be the one for the root debuggee process, but if it has exited already,
|
||||
# it will be some subprocess.
|
||||
|
|
@ -379,7 +380,7 @@ class IDE(components.Component):
|
|||
self.start_request.respond({})
|
||||
self._propagate_deferred_events()
|
||||
|
||||
# Notify the IDE of any child processes of the debuggee that aren't already
|
||||
# Notify the client of any child processes of the debuggee that aren't already
|
||||
# being debugged.
|
||||
for conn in servers.connections():
|
||||
if conn.server is None and conn.ppid == self.session.pid:
|
||||
|
|
@ -418,7 +419,7 @@ class IDE(components.Component):
|
|||
|
||||
@message_handler
|
||||
def terminate_request(self, request):
|
||||
self.session.finalize('IDE requested "terminate"', terminate_debuggee=True)
|
||||
self.session.finalize('client requested "terminate"', terminate_debuggee=True)
|
||||
return {}
|
||||
|
||||
@message_handler
|
||||
|
|
@ -426,7 +427,7 @@ class IDE(components.Component):
|
|||
terminate_debuggee = request("terminateDebuggee", bool, optional=True)
|
||||
if terminate_debuggee == ():
|
||||
terminate_debuggee = None
|
||||
self.session.finalize('IDE requested "disconnect"', terminate_debuggee)
|
||||
self.session.finalize('client requested "disconnect"', terminate_debuggee)
|
||||
return {}
|
||||
|
||||
def notify_of_subprocess(self, conn):
|
||||
|
|
@ -460,7 +461,7 @@ class IDE(components.Component):
|
|||
|
||||
def serve(host, port):
|
||||
global listener
|
||||
listener = sockets.serve("IDE", IDE, host, port)
|
||||
listener = sockets.serve("Client", Client, host, port)
|
||||
return listener.getsockname()
|
||||
|
||||
|
||||
|
|
@ -20,7 +20,7 @@ class ComponentNotAvailable(Exception):
|
|||
|
||||
|
||||
class Component(util.Observable):
|
||||
"""A component managed by a debug adapter: IDE, launcher, or debug server.
|
||||
"""A component managed by a debug adapter: client, launcher, or debug server.
|
||||
|
||||
Every component belongs to a Session, which is used for synchronization and
|
||||
shared data.
|
||||
|
|
@ -65,8 +65,8 @@ class Component(util.Observable):
|
|||
return fmt("{0}[{1}]", type(self).__name__, self.session.id)
|
||||
|
||||
@property
|
||||
def ide(self):
|
||||
return self.session.ide
|
||||
def client(self):
|
||||
return self.session.client
|
||||
|
||||
@property
|
||||
def launcher(self):
|
||||
|
|
|
|||
|
|
@ -34,16 +34,16 @@ class Launcher(components.Component):
|
|||
@message_handler
|
||||
def process_event(self, event):
|
||||
self.pid = event("systemProcessId", int)
|
||||
self.ide.propagate_after_start(event)
|
||||
self.client.propagate_after_start(event)
|
||||
|
||||
@message_handler
|
||||
def output_event(self, event):
|
||||
self.ide.propagate_after_start(event)
|
||||
self.client.propagate_after_start(event)
|
||||
|
||||
@message_handler
|
||||
def exited_event(self, event):
|
||||
self.exit_code = event("exitCode", int)
|
||||
# We don't want to tell the IDE about this just yet, because it will then
|
||||
# We don't want to tell the client about this just yet, because it will then
|
||||
# want to disconnect, and the launcher might still be waiting for keypress
|
||||
# (if wait-on-exit was enabled). Instead, we'll report the event when we
|
||||
# receive "terminated" from the launcher, right before it exits.
|
||||
|
|
@ -51,7 +51,7 @@ class Launcher(components.Component):
|
|||
@message_handler
|
||||
def terminated_event(self, event):
|
||||
try:
|
||||
self.ide.channel.send_event("exited", {"exitCode": self.exit_code})
|
||||
self.client.channel.send_event("exited", {"exitCode": self.exit_code})
|
||||
except Exception:
|
||||
pass
|
||||
self.channel.close()
|
||||
|
|
@ -94,7 +94,7 @@ def spawn_debuggee(session, start_request, sudo, args, console, console_title):
|
|||
if console == "internalConsole":
|
||||
log.info("{0} spawning launcher: {1!r}", session, cmdline)
|
||||
|
||||
# If we are talking to the IDE over stdio, sys.stdin and sys.stdout are
|
||||
# If we are talking to the client over stdio, sys.stdin and sys.stdout are
|
||||
# redirected to avoid mangling the DAP message stream. Make sure the
|
||||
# launcher also respects that.
|
||||
subprocess.Popen(
|
||||
|
|
@ -107,12 +107,9 @@ def spawn_debuggee(session, start_request, sudo, args, console, console_title):
|
|||
|
||||
else:
|
||||
log.info('{0} spawning launcher via "runInTerminal" request.', session)
|
||||
session.ide.capabilities.require("supportsRunInTerminalRequest")
|
||||
kinds = {
|
||||
"integratedTerminal": "integrated",
|
||||
"externalTerminal": "external",
|
||||
}
|
||||
session.ide.channel.request(
|
||||
session.client.capabilities.require("supportsRunInTerminalRequest")
|
||||
kinds = {"integratedTerminal": "integrated", "externalTerminal": "external"}
|
||||
session.client.channel.request(
|
||||
"runInTerminal",
|
||||
{
|
||||
"kind": kinds[console],
|
||||
|
|
@ -124,9 +121,7 @@ def spawn_debuggee(session, start_request, sudo, args, console, console_title):
|
|||
|
||||
if not session.wait_for(lambda: session.launcher, timeout=10):
|
||||
raise start_request.cant_handle(
|
||||
'{0} timed out waiting for {1} to connect',
|
||||
session,
|
||||
session.launcher,
|
||||
"{0} timed out waiting for {1} to connect", session, session.launcher
|
||||
)
|
||||
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -136,11 +136,11 @@ if 'debugpy' not in sys.modules:
|
|||
log.info("No active debug session for parent process of {0}.", self)
|
||||
else:
|
||||
try:
|
||||
parent_session.ide.notify_of_subprocess(self)
|
||||
parent_session.client.notify_of_subprocess(self)
|
||||
except Exception:
|
||||
# This might fail if the IDE concurrently disconnects from the parent
|
||||
# This might fail if the client concurrently disconnects from the parent
|
||||
# session. We still want to keep the connection around, in case the
|
||||
# IDE reconnects later. If the parent session was "launch", it'll take
|
||||
# client reconnects later. If the parent session was "launch", it'll take
|
||||
# care of closing the remaining server connections.
|
||||
log.exception("Failed to notify parent session about {0}:", self)
|
||||
|
||||
|
|
@ -159,7 +159,7 @@ if 'debugpy' not in sys.modules:
|
|||
|
||||
def request(self, request):
|
||||
raise request.isnt_valid(
|
||||
"Requests from the debug server to the IDE are not allowed."
|
||||
"Requests from the debug server to the client are not allowed."
|
||||
)
|
||||
|
||||
def event(self, event):
|
||||
|
|
@ -273,16 +273,16 @@ class Server(components.Component):
|
|||
# Do not delegate requests from the server by default. There is a security
|
||||
# boundary between the server and the adapter, and we cannot trust arbitrary
|
||||
# requests sent over that boundary, since they may contain arbitrary code
|
||||
# that the IDE will execute - e.g. "runInTerminal". The adapter must only
|
||||
# that the client will execute - e.g. "runInTerminal". The adapter must only
|
||||
# propagate requests that it knows are safe.
|
||||
raise request.isnt_valid(
|
||||
"Requests from the debug server to the IDE are not allowed."
|
||||
"Requests from the debug server to the client are not allowed."
|
||||
)
|
||||
|
||||
# Generic event handler, used if there's no specific handler below.
|
||||
@message_handler
|
||||
def event(self, event):
|
||||
self.ide.propagate_after_start(event)
|
||||
self.client.propagate_after_start(event)
|
||||
|
||||
@message_handler
|
||||
def initialized_event(self, event):
|
||||
|
|
@ -293,7 +293,7 @@ class Server(components.Component):
|
|||
def process_event(self, event):
|
||||
# If there is a launcher, it's handling the process event.
|
||||
if not self.launcher:
|
||||
self.ide.propagate_after_start(event)
|
||||
self.client.propagate_after_start(event)
|
||||
|
||||
@message_handler
|
||||
def continued_event(self, event):
|
||||
|
|
@ -306,7 +306,7 @@ class Server(components.Component):
|
|||
# in "launch" or "attach" request, which defaults to true. If explicitly set
|
||||
# to false, pydevd will only resume the thread that was stepping.
|
||||
#
|
||||
# To ensure that the IDE is aware that other threads are getting resumed in
|
||||
# To ensure that the client is aware that other threads are getting resumed in
|
||||
# that mode, pydevd sends a "continued" event with "allThreadsResumed": true.
|
||||
# when responding to a step request. This ensures correct behavior in VSCode
|
||||
# and other DAP-conformant clients.
|
||||
|
|
@ -316,14 +316,14 @@ class Server(components.Component):
|
|||
# does not expect to see "continued" events explicitly reflecting that fact.
|
||||
# If such events are sent regardless, VS behaves erratically. Thus, we have
|
||||
# to suppress them specifically for VS.
|
||||
if self.ide.client_id not in ("visualstudio", "vsformac"):
|
||||
self.ide.propagate_after_start(event)
|
||||
if self.client.client_id not in ("visualstudio", "vsformac"):
|
||||
self.client.propagate_after_start(event)
|
||||
|
||||
@message_handler
|
||||
def exited_event(self, event):
|
||||
# If there is a launcher, it's handling the exit code.
|
||||
if not self.launcher:
|
||||
self.ide.propagate_after_start(event)
|
||||
self.client.propagate_after_start(event)
|
||||
|
||||
@message_handler
|
||||
def terminated_event(self, event):
|
||||
|
|
|
|||
|
|
@ -20,16 +20,16 @@ _sessions_changed = threading.Event()
|
|||
|
||||
|
||||
class Session(util.Observable):
|
||||
"""A debug session involving an IDE, an adapter, a launcher, and a debug server.
|
||||
"""A debug session involving a client, an adapter, a launcher, and a debug server.
|
||||
|
||||
The IDE and the adapter are always present, and at least one of launcher and debug
|
||||
The client and the adapter are always present, and at least one of launcher and debug
|
||||
server is present, depending on the scenario.
|
||||
"""
|
||||
|
||||
_counter = itertools.count(1)
|
||||
|
||||
def __init__(self):
|
||||
from debugpy.adapter import ide
|
||||
from debugpy.adapter import clients
|
||||
|
||||
super(Session, self).__init__()
|
||||
|
||||
|
|
@ -37,8 +37,8 @@ class Session(util.Observable):
|
|||
self.id = next(self._counter)
|
||||
self._changed_condition = threading.Condition(self.lock)
|
||||
|
||||
self.ide = components.missing(self, ide.IDE)
|
||||
"""The IDE component. Always present."""
|
||||
self.client = components.missing(self, clients.Client)
|
||||
"""The client component. Always present."""
|
||||
|
||||
self.launcher = components.missing(self, launchers.Launcher)
|
||||
"""The launcher componet. Always present in "launch" sessions, and never
|
||||
|
|
@ -87,7 +87,7 @@ class Session(util.Observable):
|
|||
|
||||
# A session is considered ended once all components disconnect, and there
|
||||
# are no further incoming messages from anything to handle.
|
||||
components = self.ide, self.launcher, self.server
|
||||
components = self.client, self.launcher, self.server
|
||||
if all(not com or not com.is_connected for com in components):
|
||||
with _lock:
|
||||
if self in _sessions:
|
||||
|
|
@ -101,7 +101,7 @@ class Session(util.Observable):
|
|||
The predicate is invoked with the session locked. If satisfied, the method
|
||||
returns immediately. Otherwise, the lock is released (even if it was held
|
||||
at entry), and the method blocks waiting for some attribute of either self,
|
||||
self.ide, self.server, or self.launcher to change. On every change, session
|
||||
self.client, self.server, or self.launcher to change. On every change, session
|
||||
is re-locked and predicate is re-evaluated, until it is satisfied.
|
||||
|
||||
While the session is unlocked, message handlers for components other than
|
||||
|
|
@ -144,7 +144,7 @@ class Session(util.Observable):
|
|||
value of terminate; waits for it to disconnect, allowing any remaining messages
|
||||
from it to be handled; and closes the launcher channel.
|
||||
|
||||
If the IDE is present, sends "terminated" event to it.
|
||||
If the client is present, sends "terminated" event to it.
|
||||
|
||||
If terminate_debuggee=None, it is treated as True if the session has a Launcher
|
||||
component, and False otherwise.
|
||||
|
|
@ -169,7 +169,7 @@ class Session(util.Observable):
|
|||
log.info("{0} finalized.", self)
|
||||
|
||||
def _finalize(self, why, terminate_debuggee):
|
||||
# If the IDE started a session, and then disconnected before issuing "launch"
|
||||
# If the client started a session, and then disconnected before issuing "launch"
|
||||
# or "attach", the main thread will be blocked waiting for the first server
|
||||
# connection to come in - unblock it, so that we can exit.
|
||||
servers.dont_wait_for_first_connection()
|
||||
|
|
@ -217,18 +217,23 @@ class Session(util.Observable):
|
|||
except Exception:
|
||||
log.exception()
|
||||
|
||||
if self.ide:
|
||||
if self.ide.is_connected:
|
||||
# Tell the IDE that debugging is over, but don't close the channel until it
|
||||
if self.client:
|
||||
if self.client.is_connected:
|
||||
# Tell the client that debugging is over, but don't close the channel until it
|
||||
# tells us to, via the "disconnect" request.
|
||||
try:
|
||||
self.ide.channel.send_event("terminated")
|
||||
self.client.channel.send_event("terminated")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if self.ide.start_request is not None and self.ide.start_request.command == "launch":
|
||||
if (
|
||||
self.client.start_request is not None
|
||||
and self.client.start_request.command == "launch"
|
||||
):
|
||||
servers.stop_serving()
|
||||
log.info('"launch" session ended - killing remaining debuggee processes.')
|
||||
log.info(
|
||||
'"launch" session ended - killing remaining debuggee processes.'
|
||||
)
|
||||
|
||||
pids_killed = set()
|
||||
if self.launcher and self.launcher.pid is not None:
|
||||
|
|
@ -236,7 +241,11 @@ class Session(util.Observable):
|
|||
pids_killed.add(self.launcher.pid)
|
||||
|
||||
while True:
|
||||
conns = [conn for conn in servers.connections() if conn.pid not in pids_killed]
|
||||
conns = [
|
||||
conn
|
||||
for conn in servers.connections()
|
||||
if conn.pid not in pids_killed
|
||||
]
|
||||
if not len(conns):
|
||||
break
|
||||
for conn in conns:
|
||||
|
|
|
|||
|
|
@ -69,10 +69,7 @@ def serve(name, handler, host, port=0, backlog=socket.SOMAXCONN, timeout=None):
|
|||
listener = create_server(host, port, backlog, timeout)
|
||||
except Exception:
|
||||
raise log.exception(
|
||||
"Error listening for incoming {0} connections on {1}:{2}:",
|
||||
name,
|
||||
host,
|
||||
port,
|
||||
"Error listening for incoming {0} connections on {1}:{2}:", name, host, port
|
||||
)
|
||||
host, port = listener.getsockname()
|
||||
log.info("Listening for incoming {0} connections on {1}:{2}...", name, host, port)
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ switches = [
|
|||
("--wait-for-client", None, set_const("wait_for_client", True)),
|
||||
("--configure-.+", "<value>", set_config),
|
||||
|
||||
# Switches that are used internally by the IDE or debugpy itself.
|
||||
# Switches that are used internally by the client or debugpy itself.
|
||||
("--connect", "<address>", set_address("connect")),
|
||||
("--adapter-access-token", "<token>", set_arg("adapter_access_token")),
|
||||
|
||||
|
|
|
|||
|
|
@ -1,57 +0,0 @@
|
|||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the MIT License. See LICENSE in the project root
|
||||
# for license information.
|
||||
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
"""Global server options that are set via command line, environment variables,
|
||||
or configuration files.
|
||||
"""
|
||||
|
||||
target_kind = None
|
||||
"""One of: None, 'file', 'module', 'code', or 'pid'.
|
||||
"""
|
||||
|
||||
target = None
|
||||
"""Specifies what to debug.
|
||||
|
||||
If target_kind is None, then target is None, indicating that the current process
|
||||
is the one that is initiating debugger attach to itself.
|
||||
|
||||
If target_kind is 'file', then target is a path to the file to run.
|
||||
|
||||
If target_kind is 'module', then target is the qualified name of the module to run.
|
||||
|
||||
If target_kind is 'code', then target is the code to run.
|
||||
|
||||
If target_kind is 'pid', then target is the process ID to attach to.
|
||||
"""
|
||||
|
||||
host = "127.0.0.1"
|
||||
"""Name or IP address of the network interface used by debugpy.server. If runing in server
|
||||
mode, this is the interface on which it listens for incoming connections. If running
|
||||
in client mode, this is the interface to which it connects.
|
||||
"""
|
||||
|
||||
port = 5678
|
||||
"""Port number used by debugpy.server. If running in server mode, this is the port on which it
|
||||
listens for incoming connections. If running in client mode, this is port to which it
|
||||
connects.
|
||||
"""
|
||||
|
||||
client = False
|
||||
"""If True, this instance of debugpy is operating in client mode - i.e. it connects
|
||||
to the IDE, instead of waiting for an incoming connection from the IDE.
|
||||
"""
|
||||
|
||||
wait = False
|
||||
"""If True, wait until the debugger is connected before running any code."
|
||||
"""
|
||||
|
||||
multiprocess = True
|
||||
"""Whether this debugpy instance is running in multiprocess mode, detouring creation
|
||||
of new processes and enabling debugging for them.
|
||||
"""
|
||||
|
||||
client_access_token = None
|
||||
"""Access token to authenticate with the adapter."""
|
||||
|
|
@ -384,7 +384,9 @@ class Session(object):
|
|||
os.close(fd)
|
||||
|
||||
def wait_for_adapter_socket(self):
|
||||
log.info("Waiting for {0} to open the IDE listener socket...", self.adapter_id)
|
||||
log.info(
|
||||
"Waiting for {0} to open the client listener socket...", self.adapter_id
|
||||
)
|
||||
while not self.adapter_endpoints.check():
|
||||
time.sleep(0.1)
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ def test_args(pyfile, target, run):
|
|||
import sys
|
||||
import debuggee
|
||||
from debuggee import backchannel
|
||||
|
||||
|
||||
debuggee.setup()
|
||||
backchannel.send(sys.argv)
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,14 @@ def test_attach_api(pyfile, target, wait_for_client, is_client_connected, stop_m
|
|||
|
||||
backchannel = session.open_backchannel()
|
||||
session.spawn_debuggee(
|
||||
[code_to_debug, host, port, wait_for_client, is_client_connected, stop_method]
|
||||
[
|
||||
code_to_debug,
|
||||
host,
|
||||
port,
|
||||
wait_for_client,
|
||||
is_client_connected,
|
||||
stop_method,
|
||||
]
|
||||
)
|
||||
session.wait_for_adapter_socket()
|
||||
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ def test_crossfile_breakpoint(pyfile, target, run):
|
|||
import debuggee
|
||||
|
||||
debuggee.setup()
|
||||
|
||||
def do_something():
|
||||
print("do something") # @bp
|
||||
|
||||
|
|
|
|||
|
|
@ -65,7 +65,6 @@ def test_exceptions_and_exclude_rules(pyfile, target, run, scenario, exc_type):
|
|||
|
||||
@pytest.mark.parametrize("scenario", ["exclude_code_to_debug", "exclude_callback_dir"])
|
||||
def test_exceptions_and_partial_exclude_rules(pyfile, target, run, scenario):
|
||||
|
||||
@pyfile
|
||||
def code_to_debug():
|
||||
import debuggee
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ def test_module_events(pyfile, target, run):
|
|||
@pyfile
|
||||
def test_code():
|
||||
import debuggee
|
||||
|
||||
|
||||
debuggee.setup()
|
||||
|
||||
from module1 import do_something
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue