Commit 799a4912 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

selftests: net: py: capitalize defer queue and improve import



Import utils and refer to the global defer queue that way instead
of importing the queue. This will make it possible to assign value
to the global variable. While at it capitalize the name, to comply
with the Python coding style.

Reviewed-by: default avatarPetr Machata <petrm@nvidia.com>
Link: https://patch.msgid.link/20260108225257.2684238-1-kuba@kernel.org


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent de7c600e
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ import time
import traceback
from collections import namedtuple
from .consts import KSFT_MAIN_NAME
from .utils import global_defer_queue
from . import utils

KSFT_RESULT = None
KSFT_RESULT_ALL = True
@@ -157,10 +157,10 @@ def ksft_flush_defer():
    global KSFT_RESULT

    i = 0
    qlen_start = len(global_defer_queue)
    while global_defer_queue:
    qlen_start = len(utils.GLOBAL_DEFER_QUEUE)
    while utils.GLOBAL_DEFER_QUEUE:
        i += 1
        entry = global_defer_queue.pop()
        entry = utils.GLOBAL_DEFER_QUEUE.pop()
        try:
            entry.exec_only()
        except Exception:
+2 −2
Original line number Diff line number Diff line
@@ -141,7 +141,7 @@ class bkg(cmd):
        return self.process(terminate=terminate, fail=self.check_fail)


global_defer_queue = []
GLOBAL_DEFER_QUEUE = []


class defer:
@@ -153,7 +153,7 @@ class defer:
        self.args = args
        self.kwargs = kwargs

        self._queue =  global_defer_queue
        self._queue = GLOBAL_DEFER_QUEUE
        self._queue.append(self)

    def __enter__(self):