From c0cb53227eee7fb0a5d8b8d1cc213e958d9ddba2 Mon Sep 17 00:00:00 2001 From: Pavel Minaev Date: Wed, 10 Oct 2018 23:02:28 -0700 Subject: [PATCH] Gracefully handle missing 'terminated' and 'exited' events on ptvsd exit regardless of Python version - also happens on 2.x sometimes. --- pytests/helpers/session.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pytests/helpers/session.py b/pytests/helpers/session.py index 5e07382f..4913744c 100644 --- a/pytests/helpers/session.py +++ b/pytests/helpers/session.py @@ -196,10 +196,9 @@ class DebugSession(object): def wait_for_termination(self, expected_returncode=0): print(colors.LIGHT_MAGENTA + 'Waiting for ptvsd#%d to terminate' % self.ptvsd_port + colors.RESET) - if sys.version_info < (3,): - # On 3.x, ptvsd sometimes exits without sending this, likely due to - # https://github.com/Microsoft/ptvsd/issues/530 - self.wait_for_next(Event('terminated')) + # BUG: ptvsd sometimes exits without sending 'terminate' or 'exited', likely due to + # https://github.com/Microsoft/ptvsd/issues/530. So rather than wait for them, wait until + # we disconnect, then check those events for proper body only if they're actually present. self.wait_for_disconnect(close=False)