Re: Can't read in a Landsat geotiff and use multiple threads to write out different windows at the same time

Sean Gillies

The VRT_SHARED_SOURCE option only affects the connection pool within the VRT driver code and that's not relevant to your code as far as I can see.

A single opened rasterio dataset cannot be safely used by multiple threads, concurrently. There is more about this limitation at

Each of your threads will need exclusive use of a dataset object. The simplest way to achieve this is to call, sharing=False) in new threads to get a new dataset and then close it before the thread is joined. Another way is to create a suitably-sized pool of dataset objects (also using the sharing=False option) within your application and then assign these to your threads on a as-needed basis.

I hope this helps,

On Mon, May 6, 2019 at 7:02 PM <ravery@...> wrote:

I moved this github issue over here since it seems like more of a usage/help question. Below is the issue with a reproducible example if you have a Landsat tif.

The program fails at different windows when writing out windows with threads. This issue is related to this issue

I tried setting VRT_SHARED_SOURCE=0 with the rasterion.Env() context manager to allow threads to not step on each other but it didn't do anything.

Have others encountered this issue and found a solution?

Sean Gillies

Join to automatically receive all group messages.