You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by GitBox <gi...@apache.org> on 2021/05/11 20:30:02 UTC

[GitHub] [qpid-dispatch] jiridanek commented on a change in pull request #1212: DISPATCH-1930: Make sure log file is created before searching the log…

jiridanek commented on a change in pull request #1212:
URL: https://github.com/apache/qpid-dispatch/pull/1212#discussion_r630519092



##########
File path: tests/system_tests_bad_configuration.py
##########
@@ -109,15 +109,23 @@ def wait_for_unresolvable_host(self):
         then it stops scheduling new attempts.
         :return:
         """
-        with open(self.router.logfile_path, 'r') as router_log:
-            log_lines = router_log.read().split("\n")
-            expected_log_snip = "Connection to %s" % self.unresolvable_host_name
-            errors_caught = [line for line in log_lines if expected_log_snip in line and "failed" in line]
-
-            self.error_caught = any(errors_caught)
-
-            # If condition not yet satisfied and not exhausted max attempts,
-            # re-schedule the verification.
+        try:
+            with open(self.router.logfile_path, 'r') as router_log:
+                log_lines = router_log.read().split("\n")
+                expected_log_snip = "Connection to %s" % self.unresolvable_host_name
+                errors_caught = [line for line in log_lines if expected_log_snip in line and "failed" in line]
+
+                self.error_caught = any(errors_caught)
+
+                # If condition not yet satisfied and not exhausted max attempts,
+                # re-schedule the verification.
+                if self.waiting_for_error():
+                    self.attempts_made += 1
+                    self.schedule_timer()
+        except:

Review comment:
       Bare `except` is very evil in Python, because it can catch absolutely any exception, including `NameError` or `SyntaxError`. It's better to put here `except IOError`, this works on Python 2 and 3 both. For Python 3.6 only, there could be `FileNotFoundError`. Death to Python 2! May it rest in peace.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org