MCPcopy Index your code
hub / github.com/python/cpython / _connect

Function _connect

Lib/pdb.py:3416–3455  ·  view source on GitHub ↗
(
    *,
    host,
    port,
    frame,
    commands,
    version,
    signal_raising_thread,
    colorize,
)

Source from the content-addressed store, hash-verified

3414
3415
3416def _connect(
3417 *,
3418 host,
3419 port,
3420 frame,
3421 commands,
3422 version,
3423 signal_raising_thread,
3424 colorize,
3425):
3426 with closing(socket.create_connection((host, port))) as conn:
3427 sockfile = conn.makefile("rwb")
3428
3429 # The client requests this thread on Windows but not on Unix.
3430 # Most tests don't request this thread, to keep them simpler.
3431 if signal_raising_thread:
3432 signal_server = (host, port)
3433 else:
3434 signal_server = None
3435
3436 remote_pdb = _PdbServer(
3437 sockfile,
3438 signal_server=signal_server,
3439 colorize=colorize,
3440 )
3441 weakref.finalize(remote_pdb, sockfile.close)
3442
3443 if Pdb._last_pdb_instance is not None:
3444 remote_pdb.error("Another PDB instance is already attached.")
3445 elif version != remote_pdb.protocol_version():
3446 target_ver = f"0x{remote_pdb.protocol_version():08X}"
3447 attach_ver = f"0x{version:08X}"
3448 remote_pdb.error(
3449 f"The target process is running a Python version that is"
3450 f" incompatible with this PDB module."
3451 f"\nTarget process pdb protocol version: {target_ver}"
3452 f"\nLocal pdb module's protocol version: {attach_ver}"
3453 )
3454 else:
3455 remote_pdb.set_trace(frame=frame, commands=commands.splitlines())
3456
3457
3458def attach(pid, commands=()):

Callers

nothing calls this directly

Calls 9

closingClass · 0.90
_PdbServerClass · 0.85
protocol_versionMethod · 0.80
create_connectionMethod · 0.45
makefileMethod · 0.45
finalizeMethod · 0.45
errorMethod · 0.45
set_traceMethod · 0.45
splitlinesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…