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: Petr Machata <petrm@nvidia.com>
Link: https://patch.msgid.link/20260108225257.2684238-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Jakub Kicinski
2026-01-08 14:52:56 -08:00
parent de7c600e2d
commit 799a4912ee
2 changed files with 6 additions and 6 deletions

View File

@@ -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:

View File

@@ -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):