[gdal-dev] Re: GDAL/OGR Python bindings and threads

Howard Butler hobu.inc at gmail.com
Mon Apr 7 10:08:54 EDT 2008

On Apr 6, 2008, at 8:12 PM, Allen Bierbaum wrote:
> First, is this a reasonable place to post questions about the python
> bindings for GDAL/OGR or is there another list that is more
> appropriate?

gdal-dev would be more appropriate, but I would be the one who would  
take the first crack at answering the question there as well :)  http://lists.osgeo.org/mailman/listinfo/gdal-dev/ 
   Frank would then chime in with corrections to all of the  
information I got wrong ;)

> Second, assuming that this list works, does anyone have any experience
> trying to extend the OGR bindings to release the GIL during queries.
> I see that this is not enabled, but was there a specific reason for
> this? (ex: does OGR crash horribly when it is tried)

OGR is generally not thread safe (GDAL has more thread safety, but  
there are areas of the code that have not be vetted there as well),  
and I would expect that releasing the GIL inside of the bindings would  
produce awful, painful results in most cases.  Thread safety in GDAL/ 
OGR is now mostly a function of which driver you are using and whether  
or not it has been vetted to be thread safe.  The FAQ entry about  
GDAL's thread safety should apply to OGR with respect to the "core"  
stuff it talks about <http://www.gdal.org/faq.html>, but as a rule,  
OGR is less thread safe than GDAL, and for the most part, not thread  
safe at all.  Not the answer you're probably looking for, I know.

Which driver are you using that you want to do multithreaded access  
with?  If it were just PostGIS from Python, maybe psycopg2 is thread  
safe and you could query the wkb/wkt out with that and generate your  
geometries with Shapely?  That's mostly what OGR is doing in the  
background in PG's case anyway.


More information about the gdal-dev mailing list