Skip to content

Commit

Permalink
Remove running in a ProcessPoolExecutor
Browse files Browse the repository at this point in the history
  • Loading branch information
jmsmkn committed Jan 23, 2025
1 parent d51d72b commit c3875e6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# History

## 0.15.2 (2025-01-23)

* Removes running in a ProcessPoolExecutor

## 0.15.1 (2025-01-23)

* Fix potential memory leaks by confining use of `pyvips` to subprocesses
Expand Down
13 changes: 5 additions & 8 deletions panimg/image_builders/tiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import re
from collections import defaultdict
from collections.abc import Callable, Iterator
from concurrent.futures import ProcessPoolExecutor
from dataclasses import dataclass, field
from pathlib import Path
from tempfile import TemporaryDirectory
Expand Down Expand Up @@ -325,13 +324,11 @@ def _convert(
if associated_files_getter:
associated_files = associated_files_getter(gc_file.path)

with ProcessPoolExecutor(max_workers=1) as executor:
tiff_file = executor.submit(
_convert_to_tiff,
path=file,
pk=gc_file.pk,
output_directory=output_directory,
).result()
tiff_file = _convert_to_tiff(
path=file,
pk=gc_file.pk,
output_directory=output_directory,
)
except Exception as e:
file_errors[file].append(
format_error(
Expand Down
6 changes: 1 addition & 5 deletions panimg/post_processors/tiff_to_dzi.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logging
from concurrent.futures import ProcessPoolExecutor

from panimg.models import ImageType, PanImgFile, PostProcessorResult
from panimg.settings import DZI_TILE_SIZE
Expand All @@ -13,10 +12,7 @@ def tiff_to_dzi(*, image_files: set[PanImgFile]) -> PostProcessorResult:
for file in image_files:
if file.image_type == ImageType.TIFF:
try:
with ProcessPoolExecutor(max_workers=1) as executor:
result = executor.submit(
_create_dzi_image, tiff_file=file
).result()
result = _create_dzi_image(tiff_file=file)
except Exception as e:
logger.warning(f"Could not create DZI for {file}: {e}")
continue
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "panimg"
version = "0.15.1"
version = "0.15.2"
description = "Conversion of medical images to MHA and TIFF."
license = "Apache-2.0"
authors = ["James Meakin <[email protected]>"]
Expand Down

0 comments on commit c3875e6

Please sign in to comment.