Skip to content

Commit

Permalink
fix the pickling error for IO objects
Browse files Browse the repository at this point in the history
  • Loading branch information
ndonyapour authored and mr-c committed Oct 20, 2023
1 parent 56913e7 commit fd75a25
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 1 addition & 2 deletions cwltool/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import copy
import os
import shutil
import sys
import tempfile
import threading
from typing import (
Expand Down Expand Up @@ -199,7 +198,7 @@ def __init__(self, kwargs: Optional[Dict[str, Any]] = None) -> None:
self.default_stdout: Optional[Union[IO[bytes], TextIO]] = None
self.default_stderr: Optional[Union[IO[bytes], TextIO]] = None
self.validate_only: bool = False
self.validate_stdout: Union[IO[bytes], TextIO, IO[str]] = sys.stdout
self.validate_stdout: Optional[Union[IO[bytes], TextIO, IO[str]]] = None
super().__init__(kwargs)
if self.tmp_outdir_prefix == "":
self.tmp_outdir_prefix = self.tmpdir_prefix
Expand Down
9 changes: 9 additions & 0 deletions tests/test_subclass_mypyc.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,12 @@ def test_serialize_builder() -> None:
"docker",
)
assert pickle.dumps(builder)


def test_pickle_unpickle_runtime_context() -> None:
"""We can pickle & unpickle RuntimeContext"""

runtime_context = RuntimeContext()
stream = pickle.dumps(runtime_context)
assert stream
assert pickle.loads(stream)

0 comments on commit fd75a25

Please sign in to comment.