Skip to content

Commit 049c905

Browse files
committed
feat(debugger): added support for disabling the hiding of debugger threads/tasks.
By setting the ROBOTCODE_DISABLE_HIDDEN_TASKS environment variable to a value not equal to 0, the Robot Code debugger will not be hidden from the Debugpy debugger, allowing you to debug the Robot Code debugger itself.
1 parent 57692e6 commit 049c905

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

packages/core/src/robotcode/core/concurrent.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import contextlib
22
import inspect
3+
import os
34
import threading
45
from concurrent.futures import CancelledError, Future
56
from types import TracebackType
@@ -246,8 +247,12 @@ def run_as_task(callable: Callable[_P, _TResult], *args: _P.args, **kwargs: _P.k
246247
def run_as_debugpy_hidden_task(callable: Callable[_P, _TResult], *args: _P.args, **kwargs: _P.kwargs) -> Task[_TResult]:
247248
future, thread = _create_task_in_thread(callable, *args, **kwargs)
248249

249-
thread.pydev_do_not_trace = True # type: ignore[attr-defined]
250-
thread.is_pydev_daemon_thread = True # type: ignore[attr-defined]
250+
hidden_tasks = os.environ.get("ROBOTCODE_DISABLE_HIDDEN_TASKS", "0")
251+
hide = hidden_tasks == "0"
252+
253+
if hide:
254+
thread.pydev_do_not_trace = True # type: ignore[attr-defined]
255+
thread.is_pydev_daemon_thread = True # type: ignore[attr-defined]
251256

252257
thread.start()
253258

packages/debugger/src/robotcode/debugger/run.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,12 @@ async def _debug_adapter_server_async(
7575
) -> None:
7676
from .server import DebugAdapterServer
7777

78-
current_thread = threading.current_thread
79-
setattr(current_thread, "pydev_do_not_trace", True)
78+
hidden_tasks = os.environ.get("ROBOTCODE_DISABLE_HIDDEN_TASKS", "0")
79+
hide = hidden_tasks == "0"
80+
81+
if hide:
82+
current_thread = threading.current_thread
83+
setattr(current_thread, "pydev_do_not_trace", True)
8084

8185
async with DebugAdapterServer(
8286
mode=mode,
@@ -240,6 +244,7 @@ def run_debugger(
240244

241245
app.verbose("Start robot")
242246
try:
247+
app.verbose(f"Create robot context with args: {args}")
243248
robot_ctx = robot.make_context("robot", args, parent=ctx)
244249
robot.invoke(robot_ctx)
245250
except SystemExit as e:

0 commit comments

Comments
 (0)