Demonstrates why process isolation beats free-threaded Python for image work.
Generates 30 test images (up to 4K resolution) in Python via Pillow, then
creates thumbnails using the WeightedBatch strategy where batch boundaries
are determined by total pixel count. After processing, collects per-worker
memory statistics to show that Slither's backpressure kept peak memory bounded.
Why This Exists
Under free-threaded Python (PEP 703):
- Pillow's C internals (libImaging) are not thread-safe; concurrent
Image.resize(LANCZOS)can produce corrupted output or segfault - No built-in backpressure means 16 threads each loading a 4K image = 500MB+ memory spike
- One thread's segfault kills ALL threads
Under Slither:
WeightedBatchgroups images by pixel count so large images get their own batchmax_in_flight: 2caps concurrent batches (backpressure)- Each Python worker is a separate OS process, so Pillow is safe
- A crash in one worker does not affect others
Run with:
Slither.Examples.ImagePipeline.ThumbnailDemo.run_demo()
Summary
Functions
Run the full image thumbnail demo, printing results to stdout.