File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,14 +12,28 @@ def create_env():
1212 "__name__" : "__main__"
1313 }
1414
15+ debugpy_host = ""
16+ debugpy_port = 0
17+
1518def start_debug_server ():
19+ # At most one instance of debugpy can ever be created per process.
20+ # Reference: https://github.com/microsoft/debugpy/issues/297
21+ global debugpy_host , debugpy_port
22+ if debugpy_port and debugpy_port :
23+ print ("[IDACode] debugpy server is already listening on {}:{}" .format (debugpy_host , debugpy_port ))
24+ return
25+
26+ # Install hook for os.getcwd
27+ hooks .install ()
28+
29+ # Start debugpy server
1630 if settings .LOGGING :
1731 tmp_path = tempfile .gettempdir ()
1832 debugpy .log_to (tmp_path )
1933 print ("[IDACode] Logging to {} with pattern debugpy.*.log" .format (tmp_path ))
20- debugpy .configure ({ " python" : settings .PYTHON } )
21- debugpy .listen ((settings .HOST , settings .DEBUG_PORT ))
22- print ("[IDACode] IDACode debug server listening on {address }:{port }" .format (address = settings . HOST , port = settings . DEBUG_PORT ))
34+ debugpy .configure (python = settings .PYTHON )
35+ debugpy_host , debugpy_port = debugpy .listen ((settings .HOST , settings .DEBUG_PORT ))
36+ print ("[IDACode] Started debugpy server on {}:{}" .format (debugpy_host , debugpy_port ))
2337
2438class SocketHandler (tornado .websocket .WebSocketHandler ):
2539 def open (self ):
You can’t perform that action at this time.
0 commit comments