aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2021-01-29 15:32:39 -0500
committerMike Frysinger <vapier@google.com>2021-01-29 18:48:43 -0500
commitd57f9c5ac97994a9345b636f7144eba6b223cf3d (patch)
tree3a4f946762b2bda381ac50b7e6cedd5b0efaf95a
parent8349d896cdecf42a7bbd52d6a6abee1bc3acbcbf (diff)
downloadrepohooks-d57f9c5ac97994a9345b636f7144eba6b223cf3d.tar.gz
utils: drop Python 2 support
Bug: None Test: unittests pass Change-Id: I557d84808934455642026b280992cddc0c7028d7
-rw-r--r--rh/utils.py17
1 files changed, 4 insertions, 13 deletions
diff --git a/rh/utils.py b/rh/utils.py
index 1b36c7a..52a6828 100644
--- a/rh/utils.py
+++ b/rh/utils.py
@@ -183,12 +183,8 @@ def _kill_child_process(proc, int_timeout, kill_timeout, cmd, original_handler,
print('Ignoring unhandled exception in _kill_child_process: %s' % e,
file=sys.stderr)
- # Ensure our child process has been reaped.
- kwargs = {}
- if sys.version_info.major >= 3:
- # ... but don't wait forever.
- kwargs['timeout'] = 60
- proc.wait_lock_breaker(**kwargs)
+ # Ensure our child process has been reaped, but don't wait forever.
+ proc.wait_lock_breaker(timeout=60)
if not rh.signals.relay_signal(original_handler, signum, frame):
# Mock up our own, matching exit code for signaling.
@@ -310,13 +306,8 @@ def run(cmd, redirect_stdout=False, redirect_stderr=False, cwd=None, input=None,
kill_timeout = float(kill_timeout)
def _get_tempfile():
- kwargs = {}
- if sys.version_info.major < 3:
- kwargs['bufsize'] = 0
- else:
- kwargs['buffering'] = 0
try:
- return tempfile.TemporaryFile(**kwargs)
+ return tempfile.TemporaryFile(buffering=0)
except EnvironmentError as e:
if e.errno != errno.ENOENT:
raise
@@ -325,7 +316,7 @@ def run(cmd, redirect_stdout=False, redirect_stderr=False, cwd=None, input=None,
# issue in this particular case since our usage gurantees deletion,
# and since this is primarily triggered during hard cgroups
# shutdown.
- return tempfile.TemporaryFile(dir='/tmp', **kwargs)
+ return tempfile.TemporaryFile(dir='/tmp', buffering=0)
# Modify defaults based on parameters.
# Note that tempfiles must be unbuffered else attempts to read