def __init__(self, maxThreads, taskBufferSize=0, taskTimeout=0): self._mapTiles = modrana.m.get("mapTiles") self._storeTiles = modrana.m.get("storeTiles") # if task buffer size is set, start leaking # old tile download requests from the bottom of the # request stack once it becomes full, as we don't want # the work queue to block and discarding old tile # download requests is not an issue leak = taskBufferSize >= 0 self._pool = LifoThreadPool(maxThreads, name=constants.THREAD_POOL_AUTOMATIC_TILE_DOWNLOAD, taskBufferSize=taskBufferSize, leak=leak) # in seconds, 0 == no task timeout self._taskTimeout = taskTimeout self._running = set() self._runningLock = threading.RLock() # due to GIL, we don't have a lock # for the set of tile downloads # in progress (hopefully) self._imageSurface = self._mapTiles.cacheImageSurfaces