-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Opening same GPKG file/layer for write => mysterious bug #700
Comments
Can you please attach example of tiny |
You don't need one, it's created right there in the code. |
@culebron this is an interesting issue. The second call to I encourage you to only write to datasets within the context of a |
Yep. In my case
|
Just googled this bug myself another time while writing multiprocessing code. LOL. |
@culebron this remains a complicated issue. If Fiona datasets don't call GDALClose when they are deallocated, data will not be written to disk and/or memory will leak in some cases. And this is what happens in your script, GDALClose is called twice for the same file, and very late in an unexpected way the second time. Ideally, the GPKG driver should lock if it's not able to gracefully handle a double close, don't you think? I wonder if the issue isn't better solved in GDAL/OGR... maybe one of us should ask on gdal-dev to see what Even's perspective is. |
I wrote a class to stream dataframes into GeoPackage, and by mistake it opened a file for writing twice. It would succesfully write the data, but would crash when the program was terminating.
I thought it must have had something to do with threads created in the background. But turned out it was just that a condition was checked in a wrong way, and
fiona.open
ran again and again on every chunk.Here's a code that reproduces this.
My suggestion is to probably check if a layer exists (or opened for writing if possible), and at least show a warning. Because otherwise I was thinking it's because of not flushing the data, or closing it too quickly.
The text was updated successfully, but these errors were encountered: