Skip to content

Commit

Permalink
Suppress warning on exit by properly closing pydevd socket (#1826)
Browse files Browse the repository at this point in the history
* Fix #1812, first try

* Prevent tries to close socket multiple times
  • Loading branch information
bersbersbers authored Feb 5, 2025
1 parent 4c226dd commit fb0b06c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/debugpy/_vendored/pydevd/pydevd.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,8 @@ def __init__(self, set_as_global=True):

self._local_thread_trace_func = threading.local()

self._client_socket = None

self._server_socket_ready_event = ThreadingEvent()
self._server_socket_name = None

Expand Down Expand Up @@ -1504,6 +1506,7 @@ def initialize_network(self, sock, terminate_on_socket_close=True):
def connect(self, host, port):
if host:
s = start_client(host, port)
self._client_socket = s
else:
s = start_server(port)

Expand Down Expand Up @@ -2551,6 +2554,10 @@ def dispose_and_kill_all_pydevd_threads(self, wait=True, timeout=0.5):
except:
pass
finally:
if self._client_socket:
self._client_socket.close()
self._client_socket = None

pydev_log.debug("PyDB.dispose_and_kill_all_pydevd_threads: finished")

def prepare_to_run(self):
Expand Down

0 comments on commit fb0b06c

Please sign in to comment.