Skip to content

Commit b40cc2c

Browse files
authored
Close communication channel before exiting the test runner (DonJayamanne#1597)
* Close communication channel before exiting the test runner * revert change * Fixes DonJayamanne#1529
1 parent 9aba811 commit b40cc2c

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

news/2 Fixes/1529.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Close communication channel before exiting the test runner.

pythonFiles/PythonTools/visualstudio_py_testlauncher.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,20 @@ def __init__(self, socket, callback):
102102
self.seq = 0
103103
self.callback = callback
104104
self.lock = thread.allocate_lock()
105+
self._closed = False
105106
# start the testing reader thread loop
106107
self.test_thread_id = thread.start_new_thread(self.readSocket, ())
107108

109+
def close(self):
110+
self._closed = True
111+
108112
def readSocket(self):
109-
data = self.socket.recv(1024)
110-
self.callback()
113+
try:
114+
data = self.socket.recv(1024)
115+
self.callback()
116+
except OSError:
117+
if not self._closed:
118+
raise
111119

112120
def receive(self):
113121
pass
@@ -312,6 +320,8 @@ def main():
312320
else:
313321
runner = unittest.TextTestRunner(verbosity=opts.uvInt, resultclass=VsTestResult)
314322
result = runner.run(tests)
323+
if _channel is not None:
324+
_channel.close()
315325
sys.exit(not result.wasSuccessful())
316326
finally:
317327
if cov is not None:

0 commit comments

Comments
 (0)