From a42b3add4f4e0db71469d7d467de712a2fce2f73 Mon Sep 17 00:00:00 2001 From: liunux4odoo Date: Fri, 27 Sep 2024 08:40:43 +0800 Subject: [PATCH] fix lint error --- executor/engine/job/utils.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/executor/engine/job/utils.py b/executor/engine/job/utils.py index 0df6b36..0ec0a92 100644 --- a/executor/engine/job/utils.py +++ b/executor/engine/job/utils.py @@ -10,7 +10,6 @@ if T.TYPE_CHECKING: from .base import Job - JobStatusType = T.Literal['pending', 'running', 'failed', 'done', 'cancelled'] valid_job_statuses: T.List[JobStatusType] = [ 'pending', 'running', 'failed', 'done', 'cancelled'] @@ -40,7 +39,7 @@ def __init__(self, job: "Job", valid_status: T.List[JobStatusType]): _T = T.TypeVar("_T") - +_thread_locals = threading.local() def _gen_initializer(gen_func, args=tuple(), kwargs={}): # pragma: no cover global _thread_locals @@ -50,7 +49,7 @@ def _gen_initializer(gen_func, args=tuple(), kwargs={}): # pragma: no cover _thread_locals._generator = gen_func(*args, **kwargs) -def _gen_next(fut: T.Optional[Future] = None): # pragma: no cover +def _gen_next(fut = None): # pragma: no cover global _thread_locals if fut is None: return next(_thread_locals._generator) @@ -58,7 +57,7 @@ def _gen_next(fut: T.Optional[Future] = None): # pragma: no cover return next(fut) -def _gen_anext(fut: T.Optional[Future] = None): # pragma: no cover +def _gen_anext(fut = None): # pragma: no cover global _thread_locals if fut is None: return asyncio.run(_thread_locals._generator.__anext__())