@@ -120,6 +120,7 @@ async def run_robot(
120
120
output_messages : bool = False ,
121
121
output_log : bool = False ,
122
122
group_output : bool = False ,
123
+ stop_on_entry : bool = False ,
123
124
) -> Any :
124
125
import robot
125
126
@@ -128,6 +129,25 @@ async def run_robot(
128
129
from ..types import Event
129
130
from .debugger import Debugger
130
131
132
+ @_logger .call
133
+ async def start_debugpy_async () -> None :
134
+ if debugpy :
135
+ port = check_free_port (debugpy_port )
136
+ if enable_debugpy (port ):
137
+ if await asyncio .wrap_future (
138
+ asyncio .run_coroutine_threadsafe (
139
+ server .protocol .wait_for_client (wait_for_client_timeout ), loop = loop
140
+ )
141
+ ):
142
+ await asyncio .wrap_future (
143
+ asyncio .run_coroutine_threadsafe (
144
+ server .protocol .send_event_async (Event (event = "debugpyStarted" , body = {"port" : port })),
145
+ loop = loop ,
146
+ )
147
+ )
148
+ if wait_for_debugpy_client :
149
+ wait_for_debugpy_connected ()
150
+
131
151
loop = asyncio .new_event_loop ()
132
152
133
153
thread = threading .Thread (name = "RobotCode Debug Launcher" , target = run_server , args = (port , loop ))
@@ -140,28 +160,8 @@ async def run_robot(
140
160
if wait_for_client :
141
161
try :
142
162
143
- @_logger .call
144
- async def start_debugpy_async () -> None :
145
- if debugpy :
146
- port = check_free_port (debugpy_port )
147
- if enable_debugpy (port ):
148
- if await asyncio .wrap_future (
149
- asyncio .run_coroutine_threadsafe (
150
- server .protocol .wait_for_client (wait_for_client_timeout ), loop = loop
151
- )
152
- ):
153
- await asyncio .wrap_future (
154
- asyncio .run_coroutine_threadsafe (
155
- server .protocol .send_event_async (
156
- Event (event = "debugpyStarted" , body = {"port" : port })
157
- ),
158
- loop = loop ,
159
- )
160
- )
161
- wait_for_debugpy_connected ()
162
-
163
163
await asyncio .gather (
164
- start_debugpy_async (),
164
+ # start_debugpy_async(),
165
165
asyncio .wrap_future (
166
166
asyncio .run_coroutine_threadsafe (
167
167
server .protocol .wait_for_client (wait_for_client_timeout ), loop = loop
@@ -186,23 +186,23 @@ async def start_debugpy_async() -> None:
186
186
except asyncio .TimeoutError :
187
187
raise ConnectionError ("Timeout to get configuration from client." )
188
188
189
+ await start_debugpy_async ()
190
+
189
191
args = [
190
192
"--listener" ,
191
193
f"robotcode.debug_adapter.launcher.listeners.ListenerV2:no_debug={ repr (no_debug )} " ,
192
194
* args ,
193
195
]
194
196
197
+ Debugger .instance ().stop_on_entry = stop_on_entry
195
198
Debugger .instance ().output_messages = output_messages
196
199
Debugger .instance ().output_log = output_log
197
200
Debugger .instance ().group_output = group_output
198
201
199
202
Debugger .instance ().set_main_thread (threading .current_thread ())
200
203
Debugger .instance ().start ()
201
204
202
- exit_code = robot .run_cli (
203
- args ,
204
- False ,
205
- )
205
+ exit_code = robot .run_cli (args , False )
206
206
207
207
if server .protocol .connected :
208
208
await asyncio .wrap_future (
@@ -327,6 +327,7 @@ def main() -> None:
327
327
parser .add_argument (
328
328
"-og" , "--group-output" , action = "store_true" , help = "Fold messages/log from robotframework to client."
329
329
)
330
+ parser .add_argument ("-soe" , "--stop-on-entry" , action = "store_true" , help = "Stops on entry." )
330
331
331
332
sys_args = sys .argv [1 :]
332
333
@@ -406,6 +407,7 @@ def main() -> None:
406
407
args .output_messages ,
407
408
args .output_log ,
408
409
args .group_output ,
410
+ args .stop_on_entry ,
409
411
)
410
412
)
411
413
0 commit comments