Skip to content

Commit

Permalink
Use RIO_TILER_MAX_THREADS in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodrigo Almeida committed Oct 7, 2021
1 parent e9de432 commit 1e2912b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/mosaic.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ rio_tiler.mosaic.mosaic_reader(
*args: Any,
pixel_selection: Union[Type[MosaicMethodBase], MosaicMethodBase] = FirstMethod,
chunk_size: Optional[int] = None,
threads: int = MAX_THREADS,
threads: int = RIO_TILER_MAX_THREADS,
allowed_exceptions: Tuple = (TileOutsideBounds,),
**kwargs,
)
Expand Down Expand Up @@ -127,14 +127,14 @@ mosaic_assets = ["1.tif", "2.tif", "3.tif", "4.tif", "5.tif", "6.tif"]
for chunks in _chunks(mosaic_assets, chunk_size):

# 2nd level loop - Uses threads for process each `chunck`
with futures.ThreadPoolExecutor(max_workers=max_threads) as executor:
with futures.ThreadPoolExecutor(max_workers=RIO_TILER_MAX_THREADS) as executor:
future_tasks = [(executor.submit(_tiler, asset), asset) for asset in chunks]
```
By default the chunck_size is equal to the number or threads (or the number of assets if no threads=0)

#### More on threading

The number of threads used can be set in the function call with the `threads=` options. By default it will be equal to `multiprocessing.cpu_count() * 5` or to the `MAX_THREADS` environment variable.
The number of threads used can be set in the function call with the `threads=` options. By default it will be equal to `multiprocessing.cpu_count() * 5` or to the `RIO_TILER_MAX_THREADS` environment variable.
In some case, threading can slow down your application. You can set threads to `0` or `1` to run the tiler in a loop without using a ThreadPool (ref: [#207](https://github.com/cogeotiff/rio-tiler/issues/207)).

Benchmark:
Expand Down

0 comments on commit 1e2912b

Please sign in to comment.