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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]