From c6eb7ee3e574b48ee016dd31af2014b0ed083268 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Sat, 30 Apr 2016 13:34:04 -0400 Subject: Use contextlib.suppress() where appropriate. --- src/mailman/testing/helpers.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/mailman/testing/helpers.py') diff --git a/src/mailman/testing/helpers.py b/src/mailman/testing/helpers.py index 3edd66479..a87dd58ec 100644 --- a/src/mailman/testing/helpers.py +++ b/src/mailman/testing/helpers.py @@ -31,7 +31,7 @@ import datetime import threading from base64 import b64encode -from contextlib import contextmanager +from contextlib import contextmanager, suppress from email import message_from_string from httplib2 import Http from lazr.config import as_timedelta @@ -183,14 +183,11 @@ class TestableMaster(Master): starting_kids = set(self._kids) while starting_kids: for pid in self._kids: - try: + # Ignore the exception which gets raised when the child has + # not yet started. + with suppress(ProcessLookupError): os.kill(pid, 0) starting_kids.remove(pid) - except OSError as error: - if error.errno == errno.ESRCH: - # The child has not yet started. - pass - raise # Keeping a copy of all the started child processes for use by the # testing environment, even after all have exited. self._started_kids = set(self._kids) -- cgit v1.2.3-70-g09d2