Skip to content

Commit fb0b06c

Browse files
authored
Suppress warning on exit by properly closing pydevd socket (#1826)
* Fix #1812, first try * Prevent tries to close socket multiple times
1 parent 4c226dd commit fb0b06c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/debugpy/_vendored/pydevd/pydevd.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,8 @@ def __init__(self, set_as_global=True):
726726

727727
self._local_thread_trace_func = threading.local()
728728

729+
self._client_socket = None
730+
729731
self._server_socket_ready_event = ThreadingEvent()
730732
self._server_socket_name = None
731733

@@ -1504,6 +1506,7 @@ def initialize_network(self, sock, terminate_on_socket_close=True):
15041506
def connect(self, host, port):
15051507
if host:
15061508
s = start_client(host, port)
1509+
self._client_socket = s
15071510
else:
15081511
s = start_server(port)
15091512

@@ -2551,6 +2554,10 @@ def dispose_and_kill_all_pydevd_threads(self, wait=True, timeout=0.5):
25512554
except:
25522555
pass
25532556
finally:
2557+
if self._client_socket:
2558+
self._client_socket.close()
2559+
self._client_socket = None
2560+
25542561
pydev_log.debug("PyDB.dispose_and_kill_all_pydevd_threads: finished")
25552562

25562563
def prepare_to_run(self):

0 commit comments

Comments
 (0)