fix debugger detection

This commit is contained in:
Aran-Fey
2025-11-17 18:38:43 +01:00
parent 069831322e
commit adc9c8d783
2 changed files with 22 additions and 1 deletions
+5
View File
@@ -3130,6 +3130,11 @@ a.remove();
self,
properties_to_serialize: IdentityDefaultDict[object, set[str]],
):
# TODO: This function can probably be optimized in some way. Ideas:
# 1. Maintain a permanent `component_level` cache
# 2. Find the topmost components at the start and then just iteratively
# yield their children
components_to_build = set[rio.Component]()
permanent_component_level_cache: dict[rio.Component, int] = {}
+17 -1
View File
@@ -28,7 +28,23 @@ __all__ = ["BrowserClient", "prepare_browser_client"]
#
# Note: Chrome's console doesn't show `console.debug` messages per default. To
# see them, click on "All levels" and check "Verbose".
DEBUGGER_ACTIVE = sys.gettrace() is not None
def debugger_active():
try:
if sys.gettrace() is not None:
return True
except AttributeError:
pass
try:
if sys.monitoring.get_tool(sys.monitoring.DEBUGGER_ID) is not None: # type: ignore
return True
except AttributeError:
pass
return False
DEBUGGER_ACTIVE = debugger_active()
server_manager: ServerManager | None = None