Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Fix for error message on program exit #25

Merged
merged 2 commits into from
Jan 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion ptvsd/debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ def debug(filename, port_num, debug_id, debug_options, run_as):
'--client', '127.0.0.1',
'--file', filename,
]
pydevd.main()
try:
pydevd.main()
except SystemExit as ex:
ptvsd.wrapper.ptvsd_sys_exit_code = ex.code
raise
8 changes: 8 additions & 0 deletions ptvsd/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# TODO: with_statement is not needed
from __future__ import print_function, with_statement, absolute_import

import atexit
import os
import socket
import sys
Expand Down Expand Up @@ -33,6 +34,7 @@
# print(s)
#ipcjson._TRACE = ipcjson_trace

ptvsd_sys_exit_code = 0

def unquote(s):
if s is None:
Expand Down Expand Up @@ -244,6 +246,8 @@ def __init__(self, socket, pydevd, logfile=None):

def close(self):
# TODO: docstring
global ptvsd_sys_exit_code
self.send_event('exited', exitCode=ptvsd_sys_exit_code)
if self.socket:
self.socket.close()

Expand Down Expand Up @@ -700,6 +704,8 @@ def start_server(port):
server_thread.daemon = True
server_thread.start()

atexit.register(proc.close)

return pydevd


Expand All @@ -719,6 +725,8 @@ def start_client(host, port):
server_thread.daemon = True
server_thread.start()

atexit.register(proc.close)

return pydevd


Expand Down