Skip to content

Low-priority fixes (v2.2.2)#16

Merged
vladiant merged 4 commits into
mainfrom
low_prio_fixes
Apr 3, 2026
Merged

Low-priority fixes (v2.2.2)#16
vladiant merged 4 commits into
mainfrom
low_prio_fixes

Conversation

@vladiant
Copy link
Copy Markdown
Collaborator

@vladiant vladiant commented Apr 3, 2026

Summary

Three internal bug fixes addressing config wiring, async correctness, and graceful shutdown. No new features or breaking API changes.

Changes

1. Wire IMG_THUMBNAIL_MAX_SIZE to the image processor

IMG_THUMBNAIL_MAX_SIZE was defined in config but never consumed — thumbnails always used the hardcoded (256, 256) default. Now:

  • PillowImageProcessor accepts thumbnail_max_size in its constructor and uses it as the default for generate_thumbnail.
  • The DI factory reads settings.thumbnail_max_size and passes it through.
  • The domain interface signature updated to max_size: tuple[int, int] | None = None so implementations control their own defaults.

Files: image_processor.py, pillow_processor.py, dependencies.py

2. Replace threading.Lock with asyncio.Lock in cache

InMemoryImageCache used threading.Lock, which blocks the event loop under concurrent async access. All cache methods (get, set, invalidate, clear) are now async with asyncio.Lock. CachedImageRepository updated to await all cache calls.

Files: in_memory_cache.py, cached_image_repository.py

3. Async executor shutdown with timeout

ProcessPoolExecutor.shutdown(wait=True) was called synchronously in the lifespan, blocking the event loop indefinitely if workers hung. New async_shutdown_executor() runs the shutdown in a thread with a 30-second timeout, then force-cancels remaining workers via shutdown(wait=False, cancel_futures=True).

Files: pillow_processor.py, main.py

Test changes

  • Cache unit tests and concurrency tests converted from sync/threading to async/asyncio.gather.
  • Lifespan tests updated to mock async_shutdown_executor instead of shutdown_executor.
  • All 216 tests pass.

Checklist

  • ruff check — all passed
  • mypy src/ — no issues (52 source files)
  • pytest — 216 passed
  • CHANGELOG.md updated
  • Version bumped: 2.2.12.2.2 (PATCH — bug fixes only)

@vladiant vladiant merged commit a13cbfc into main Apr 3, 2026
4 checks passed
@vladiant vladiant deleted the low_prio_fixes branch April 3, 2026 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant