zooui.tilesystem.tilemanager module

The TileManager is responsible for requesting tiles from TileProviders, caching them in memory, and providing them to MediaObjects when requested to do so.

It is also responsible for creating new tiles from available ones when no tiles of the requested resolution are available.

zooui.tilesystem.tilemanager.init(total_cache_size=1024, auto_cleanup=True, cleanup_max_age_days=3, collect_cleanup_stats=False)[source]
Function :

init(total_cache_size, auto_cleanup, cleanup_max_age_days, collect_cleanup_stats)

Parameters :
total_cache_sizeint
  • Total cache size: number of total cached tiles (default: 1024)

auto_cleanupbool
  • Enable automatic cleanup of old tiles (default: True)

cleanup_max_age_daysint
  • Maximum age in days for tiles (default: 3)

collect_cleanup_statsbool
  • Collect detailed before/after cleanup statistics (default: False)

  • Setting to False improves startup performance on large tilestores

init(total_cache_size, auto_cleanup, cleanup_max_age_days, collect_cleanup_stats) –> None

Initialise the TileManager. This must be called before any other functions are called.

The central coordinator that:
  • Routes tile requests to appropriate providers

  • Manages two-tier caching (80% permanent / 20% temporary)

  • Synthesizes missing tiles from available ones via cut_tile()

  • Key methods: load_tile(), get_tile(), get_tile_robust()

zooui.tilesystem.tilemanager.shutdown()[source]

Stop all tile provider threads and tile cache threads.

This should be called during application shutdown (via aboutToQuit) to ensure background threads are joined before Qt begins destroying its internals.

zooui.tilesystem.tilemanager._shutdown_threads()[source]

Stop and join all TileProvider and TileCache background threads.

zooui.tilesystem.tilemanager._shutdown_cleanup()[source]
Function :

_shutdown_cleanup()

Parameters :

None

_shutdown_cleanup() –> None

Execute tilestore cleanup on application shutdown.

This function is registered with atexit and connected to Qt’s aboutToQuit signal. It runs cleanup with stored parameters and prevents duplicate execution.

zooui.tilesystem.tilemanager.load_tile(tile_id)[source]
Function :

load_tile(tile_id)

Parameters :

tile_id : Tuple[str, int, int, int]

load_tile(tile_id) –> None

Request that the tile identified by tile_id be loaded into the tilecache.

zooui.tilesystem.tilemanager.get_tile(tile_id)[source]
Function :

get_tile(tile_id)

Parameters :

tile_id : Tuple[str, int, int, int]

get_tile(tile_id) –> Tile

Return the requested tile identified by tile_id.

If the tile is not available in the tilecache, one of three errors will be raised: MediaNotTiled, TileNotLoaded, or TileNotAvailable

zooui.tilesystem.tilemanager.cut_tile(tile_id, tempcache=0)[source]
Function :

cut_tile(tile_id, tempcache)

Parameters :

tile_id : Tuple[str, int, int, int] tempcache : int

cut_tile(tile_id, tempcache) –> Tuple[Tile, bool]

Create a tile from resizing and cropping those loaded into the tile cache. Returns a tuple containing the tile, and a bool final which is False iff the tile is not the greatest resolution possible and should therefore not be cached indefinitely.

If tempcache > 0, then tiles with final`=False will cached in the :class:`TileCache, but will expire after they have been accessed tempcache times.

This function should only be called if a TileNotLoaded or TileNotAvailable error has been encountered.

Precondition: the (0,0,0) tile exists for the given media Precondition: the requested tile doesn’t fall outside the bounds of the image

zooui.tilesystem.tilemanager.get_tile_robust(tile_id)[source]
Function :

get_tile_robust(tile_id)

Parameters :

tile_id : Tuple[str, int, int, int]

get_tile_robust(tile_id) –> Tile

Will try returning the result of get_tile(), and if that fails will return the result of cut_tile().

This function will not raise TileNotLoaded or TileNotAvailable, but may raise MediaNotTiled.

zooui.tilesystem.tilemanager.tiled(media_id)[source]
Function :

tiled(media_id)

Parameters :

media_id : str

tiled(media_id) –> bool

Returns True iff the media identified by media_id has been tiled.

Will always return True for dynamic media.

zooui.tilesystem.tilemanager.get_metadata(media_id, key)[source]
Function :

get_metadata(media_id, key)

Parameters :

media_id : str key : str

get_metadata(media_id, key) –> object or None

Return the value associated with the given metadata key for the given media_id, None if there is no such value.

zooui.tilesystem.tilemanager.purge(media_id=None)[source]
Function :

purge(media_id)

Parameters :

media_id : Optional[str]

purge(media_id) –> None

Purge the specified media_id from the TileProviders. If media_id is omitted then all media will be purged.

Precondition: the media to be purged should not be active (i.e. no MediaObjects for the media should exist).

zooui.tilesystem.tilemanager.pause()[source]
Function :

pause()

Parameters :

None

pause() –> None

Pause all TileProvider threads. This should be called before running converter processes to avoid conflicts between pyvips and tile loading.

zooui.tilesystem.tilemanager.resume()[source]
Function :

resume()

Parameters :

None

resume() –> None

Resume all TileProvider threads after they were paused.

exception zooui.tilesystem.tilemanager.MediaNotTiled[source]

Bases: Exception

Exception for when tiles are requested from a media that has not been tiled yet.

This exception will never be thrown when requesting a tile from a dynamic media.

exception zooui.tilesystem.tilemanager.TileNotLoaded[source]

Bases: Exception

Exception for when tiles are requested before they have been loaded into the tile cache.

exception zooui.tilesystem.tilemanager.TileNotAvailable[source]

Bases: Exception

Exception for when an attempt to load the requested tile has previously failed.