gallery_screen_base
anomaly_match_ui.screens.gallery_screen_base
¶
Base class for screens with a DB-backed paginated gallery.
Provides shared infrastructure for gallery refresh, DB polling, score
histogram, stats panel, image detail navigation, and prefetching.
Subclasses implement :meth:build to compose their own layout and
override hooks for custom progress display and poll intervals.
Threading model¶
Foreground executor (_executor, thread_name_prefix="am",
max_workers=4):
User-driven, latency-sensitive tasks. Sized so a click can run
even when other foreground work is in flight.
- *page-load* — loads thumbnail images for the current gallery page
- *detail-load* — loads a full image on magnify click
Prefetch executor (_prefetch_executor,
thread_name_prefix="am_prefetch", max_workers=1):
Background work that must never starve the foreground lane. A
wedged Cutana parquet read here can't queue ahead of clicks (#444).
- *prefetch* — warms the image cache for the pages around the
current one (window prefetch), cancel-on-navigate
The underscore in the prefix is deliberate: the UI conftest joins
every ``am-*``-named thread on test teardown to keep ``am-poll``
from racing the SQLite GC at interpreter shutdown, and an idle
``ThreadPoolExecutor`` worker blocked in ``queue.get()`` would
eat the full join timeout (~2s) per test under that prefix.
Managed threads (explicit threading.Thread):
Long-running threads that need Event-based cancellation.
- *poll* (``am-poll``) — polls the DB every N seconds until stopped
GalleryScreenBase(app)
¶
Bases: BaseScreen
Base for screens with a DB-backed paginated image gallery.
Provides gallery refresh, DB polling, histogram, stats panel,
image detail navigation, prefetching, and common UI helpers.
Subclasses must implement :meth:build and may override hooks
like :meth:_get_poll_interval and :meth:_update_poll_progress.
Subclasses must assign the following attributes in their
:meth:build before returning:
self.gallery— a :class:GalleryWidgetself.stats_html— :class:widgets.HTMLfor statisticsself._histogram_image— :class:widgets.Imagefor the histogramself.status_html— :class:widgets.HTMLfor status textself.progress— a :class:ProgressPanelself.out— :class:widgets.Outputfor terminal logging
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app
|
AnomalyMatchApp
|
The parent application instance used for navigation. |
required |