MCPcopy Create free account
hub / github.com/microsoft/debugpy / wait_for_connection

Function wait_for_connection

src/debugpy/adapter/servers.py:421–452  ·  view source on GitHub ↗

Waits until there is a server matching the specified predicate connected to this adapter, and returns the corresponding Connection. If there is more than one server connection already available, returns the oldest one.

(session, predicate, timeout=None)

Source from the content-addressed store, hash-verified

419
420
421def wait_for_connection(session, predicate, timeout=None):
422 """Waits until there is a server matching the specified predicate connected to
423 this adapter, and returns the corresponding Connection.
424
425 If there is more than one server connection already available, returns the oldest
426 one.
427 """
428
429 def wait_for_timeout():
430 time.sleep(timeout)
431 wait_for_timeout.timed_out = True
432 with _lock:
433 _connections_changed.set()
434
435 wait_for_timeout.timed_out = timeout == 0
436 if timeout:
437 thread = threading.Thread(
438 target=wait_for_timeout, name="servers.wait_for_connection() timeout"
439 )
440 thread.daemon = True
441 thread.start()
442
443 if timeout != 0:
444 log.info("{0} waiting for connection from debug server...", session)
445 while True:
446 with _lock:
447 _connections_changed.clear()
448 conns = (conn for conn in _connections if predicate(conn))
449 conn = next(conns, None)
450 if conn is not None or wait_for_timeout.timed_out:
451 return conn
452 _connections_changed.wait()
453
454
455def wait_until_disconnected():

Callers 1

disconnectMethod · 0.85

Calls 4

infoMethod · 0.80
startMethod · 0.45
clearMethod · 0.45
waitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…