@@ -81,6 +81,7 @@ async def _debug_adapter_server_(host: str, port: int) -> None:
8181async def start_debugpy_async (
8282 server : "DebugAdapterServer" ,
8383 debugpy_port : int = 5678 ,
84+ addresses : Union [Sequence [str ], str , None ] = None ,
8485 wait_for_debugpy_client : bool = False ,
8586 wait_for_client_timeout : float = DEFAULT_TIMEOUT ,
8687) -> None :
@@ -93,12 +94,14 @@ async def start_debugpy_async(
9394 if port != debugpy_port :
9495 _logger .warning (f"start debugpy session on port { port } " )
9596
96- if enable_debugpy (port ) and await run_coroutine_from_thread_async (
97+ if enable_debugpy (port , addresses ) and await run_coroutine_from_thread_async (
9798 server .protocol .wait_for_client , wait_for_client_timeout , loop = server .loop
9899 ):
99100 await asyncio .wrap_future (
100101 asyncio .run_coroutine_threadsafe (
101- server .protocol .send_event_async (Event (event = "debugpyStarted" , body = {"port" : port })),
102+ server .protocol .send_event_async (
103+ Event (event = "debugpyStarted" , body = {"port" : port , "addresses" : addresses })
104+ ),
102105 loop = server .loop ,
103106 )
104107 )
@@ -110,7 +113,7 @@ async def start_debugpy_async(
110113async def run_robot (
111114 port : int ,
112115 args : List [str ],
113- bind : Union [Sequence [str ], str , None ] = None ,
116+ addresses : Union [Sequence [str ], str , None ] = None ,
114117 no_debug : bool = False ,
115118 wait_for_client : bool = False ,
116119 wait_for_client_timeout : float = DEFAULT_TIMEOUT ,
@@ -129,10 +132,14 @@ async def run_robot(
129132 run_coroutine_from_thread_async ,
130133 run_coroutine_in_thread ,
131134 )
135+ from ..utils .debugpy import is_debugpy_installed
132136 from .dap_types import Event
133137 from .debugger import Debugger
134138
135- server_future = run_coroutine_in_thread (_debug_adapter_server_ , bind , port )
139+ if debugpy and not is_debugpy_installed ():
140+ print ("debugpy not installed." )
141+
142+ server_future = run_coroutine_in_thread (_debug_adapter_server_ , addresses , port )
136143
137144 server = await wait_for_server ()
138145
@@ -147,7 +154,7 @@ async def run_robot(
147154 except asyncio .TimeoutError as e :
148155 raise ConnectionError ("No incomming connection from a debugger client." ) from e
149156
150- await run_coroutine_from_thread_async (server .protocol .initialized , loop = server .loop )
157+ await run_coroutine_from_thread_async (server .protocol .wait_for_initialized , loop = server .loop )
151158
152159 if wait_for_client :
153160 try :
@@ -160,7 +167,7 @@ async def run_robot(
160167 raise ConnectionError ("Timeout to get configuration from client." ) from e
161168
162169 if debugpy :
163- await start_debugpy_async (server , debugpy_port , wait_for_debugpy_client , wait_for_client_timeout )
170+ await start_debugpy_async (server , debugpy_port , addresses , wait_for_debugpy_client , wait_for_client_timeout )
164171
165172 args = [
166173 "--listener" ,
0 commit comments