Skip to content

Commit

Permalink
Formatting and improve comment
Browse files Browse the repository at this point in the history
  • Loading branch information
pkcakeout committed Jan 21, 2025
1 parent 1637d31 commit 1fbb52c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
9 changes: 6 additions & 3 deletions panimg/image_builders/tiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
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
from typing import DefaultDict
from uuid import UUID, uuid4
from concurrent.futures import ProcessPoolExecutor

import tifffile

Expand Down Expand Up @@ -337,9 +337,12 @@ def _convert(

# If this is a globally importable value like "pyvips",
# we ship it as string and look it up in _convert_to_tiff
# otherwise we pass the value directly
# otherwise we pass the value directly so that it can be
# used in the subprocess with proper resource isolation
if converter in globals().values():
serialized_converter = [k for k, v in globals().items() if v == converter].pop()
serialized_converter = [
k for k, v in globals().items() if v == converter
].pop()
else:
serialized_converter = converter

Expand Down
7 changes: 4 additions & 3 deletions panimg/post_processors/tiff_to_dzi.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import logging
from concurrent.futures import ProcessPoolExecutor

from panimg.models import ImageType, PanImgFile, PostProcessorResult
from panimg.settings import DZI_TILE_SIZE

from concurrent.futures import ProcessPoolExecutor

try:
import pyvips
except OSError:
Expand All @@ -28,7 +27,9 @@ def tiff_to_dzi(*, image_files: set[PanImgFile]) -> PostProcessorResult:
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 = executor.submit(
_create_dzi_image, tiff_file=file
).result()
except Exception as e:
logger.warning(f"Could not create DZI for {file}: {e}")
continue
Expand Down

0 comments on commit 1fbb52c

Please sign in to comment.