From: Zack Cerza Date: Fri, 17 Mar 2023 01:20:22 +0000 (-0600) Subject: task.kernel: Make task() a context manager X-Git-Tag: 1.2.0~118^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=4e866680d1fd44e008b3ab6e208c4d2c80f02d2c;p=teuthology.git task.kernel: Make task() a context manager This will cause it to be instrumented for timing via the bits in run_tasks. Signed-off-by: Zack Cerza --- diff --git a/teuthology/task/kernel.py b/teuthology/task/kernel.py index 8879963caf..c0c2a1f553 100644 --- a/teuthology/task/kernel.py +++ b/teuthology/task/kernel.py @@ -2,6 +2,7 @@ Kernel installation task """ +import contextlib import logging import os import re @@ -1130,6 +1131,7 @@ def get_sha1_from_pkg_name(path): return sha1 +@contextlib.contextmanager def task(ctx, config): """ Make sure the specified kernel is installed. @@ -1234,6 +1236,11 @@ def task(ctx, config): for role, role_config in config.items(): p.spawn(process_role, ctx, config, timeout, role, role_config) + try: + yield + finally: + pass + def process_role(ctx, config, timeout, role, role_config): need_install = None # sha1 to dl, or path to rpm or deb