Skip to content

Commit 99aec49

Browse files
committed
creating a type union with the pipe operator is not support by threading.Lock
until Python 3.13 python/cpython#114315 fixed in 3.13 python/cpython@d96358f
1 parent e9582d4 commit 99aec49

File tree

5 files changed

+12
-10
lines changed

5 files changed

+12
-10
lines changed

cwltool/command_line_tool.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def __init__(
179179
def run(
180180
self,
181181
runtimeContext: RuntimeContext,
182-
tmpdir_lock: threading.Lock | None = None,
182+
tmpdir_lock: Union[threading.Lock, None] = None,
183183
) -> None:
184184
try:
185185
normalizeFilesDirs(self.builder.job)
@@ -329,7 +329,7 @@ def __init__(
329329
def run(
330330
self,
331331
runtimeContext: RuntimeContext,
332-
tmpdir_lock: threading.Lock | None = None,
332+
tmpdir_lock: Union[threading.Lock, None] = None,
333333
) -> None:
334334
if self.output_callback:
335335
self.output_callback(

cwltool/context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def __init__(self, kwargs: dict[str, Any] | None = None) -> None:
180180
self.cidfile_dir: str | None = None
181181
self.cidfile_prefix: str | None = None
182182

183-
self.workflow_eval_lock: threading.Condition | None = None
183+
self.workflow_eval_lock: Union[threading.Condition, None] = None
184184
self.research_obj: ResearchObject | None = None
185185
self.orcid: str = ""
186186
self.cwl_full_name: str = ""

cwltool/job.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ def __repr__(self) -> str:
161161
def run(
162162
self,
163163
runtimeContext: RuntimeContext,
164-
tmpdir_lock: threading.Lock | None = None,
164+
tmpdir_lock: Union[threading.Lock, None] = None,
165+
# use `threading.Lock | None` when we drop support for Python 3.12
165166
) -> None:
166167
pass
167168

@@ -566,7 +567,7 @@ class CommandLineJob(JobBase):
566567
def run(
567568
self,
568569
runtimeContext: RuntimeContext,
569-
tmpdir_lock: threading.Lock | None = None,
570+
tmpdir_lock: Union[threading.Lock, None] = None,
570571
) -> None:
571572
if tmpdir_lock:
572573
with tmpdir_lock:
@@ -752,7 +753,7 @@ def add_volumes(
752753
def run(
753754
self,
754755
runtimeContext: RuntimeContext,
755-
tmpdir_lock: threading.Lock | None = None,
756+
tmpdir_lock: Union[threading.Lock, None] = None,
756757
) -> None:
757758
debug = runtimeContext.debug
758759
if tmpdir_lock:

cwltool/task_queue.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import queue
77
import threading
88
from collections.abc import Callable
9+
from typing import Union
910

1011
from .loghandler import _logger
1112

@@ -65,8 +66,8 @@ def _task_queue_func(self) -> None:
6566
def add(
6667
self,
6768
task: Callable[[], None],
68-
unlock: threading.Condition | None = None,
69-
check_done: threading.Event | None = None,
69+
unlock: Union[threading.Condition, None] = None,
70+
check_done: Union[threading.Event, None] = None,
7071
) -> None:
7172
"""
7273
Add your task to the queue.

cwltool/workflow_job.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import logging
55
import threading
66
from collections.abc import MutableMapping, MutableSequence, Sized
7-
from typing import Optional, TYPE_CHECKING, cast
7+
from typing import TYPE_CHECKING, Optional, Union, cast
88

99
from cwl_utils import expression
1010
from cwl_utils.types import CWLObjectType, CWLOutputType, SinkType
@@ -764,7 +764,7 @@ def valueFromFunc(k: str, v: CWLOutputType | None) -> CWLOutputType | None:
764764
def run(
765765
self,
766766
runtimeContext: RuntimeContext,
767-
tmpdir_lock: threading.Lock | None = None,
767+
tmpdir_lock: Union[threading.Lock, None] = None,
768768
) -> None:
769769
"""Log the start of each workflow."""
770770
_logger.info("[%s] start", self.name)

0 commit comments

Comments
 (0)