From c268bde43045a5c2ad6591d7c191ad698d4bcbcf Mon Sep 17 00:00:00 2001 From: H0bo Date: Tue, 7 Apr 2020 17:30:42 +0200 Subject: [PATCH] _get_responses_windows uses same timeout mechanism as unix codepath (#37) --- pygdbmi/gdbcontroller.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/pygdbmi/gdbcontroller.py b/pygdbmi/gdbcontroller.py index 9179d8b..57dc18a 100644 --- a/pygdbmi/gdbcontroller.py +++ b/pygdbmi/gdbcontroller.py @@ -293,6 +293,7 @@ def _get_responses_windows(self, timeout_sec): timeout_time_sec = time.time() + timeout_sec responses = [] while True: + responses_list = [] try: self.gdb_process.stdout.flush() if PYTHON3: @@ -301,7 +302,7 @@ def _get_responses_windows(self, timeout_sec): ) else: raw_output = self.gdb_process.stdout.read().replace(b"\r", b"\n") - responses += self._get_responses_list(raw_output, "stdout") + responses_list = self._get_responses_list(raw_output, "stdout") except IOError: pass @@ -313,11 +314,19 @@ def _get_responses_windows(self, timeout_sec): ) else: raw_output = self.gdb_process.stderr.read().replace(b"\r", b"\n") - responses += self._get_responses_list(raw_output, "stderr") + responses_list += self._get_responses_list(raw_output, "stderr") except IOError: pass - if time.time() > timeout_time_sec: + responses += responses_list + if timeout_sec == 0: + break + elif responses_list and self._allow_overwrite_timeout_times: + timeout_time_sec = min( + time.time() + self.time_to_check_for_additional_output_sec, + timeout_time_sec, + ) + elif time.time() > timeout_time_sec: break return responses