The only idea that I have off the top of my head is to use
threading.local in order to keep track of a handle for each thread
that calls any function in GEOS. I tried implementing something like
this quickly and ran into problems. Any other ideas?

-Aron

On Mon, Jan 26, 2009 at 9:31 PM, Sean Gillies <[email protected]> wrote:
> Oh, right. I only meant that GEOSDisjoint (for example) calls
> GEOSDisjoint_r as you can see in
>
> http://trac.osgeo.org/geos/browser/trunk/capi/geos_c.cpp#L94
>
> Thread safety hasn't been a problem up to now, and we've hammered on
> it quite a bit. We're using PyDLL to load libgeos_c, which means the
> GIL isn't released.
>
> Let's do test the reentrant GEOS API, switching to CDLL in Shapely so
> that the GIL is released. I'd like to take advantage of this. It would
> be nice to make the context handling transparent to users, yes? Any
> ideas?
>
> Sean
>
> On Jan 26, 2009, at 6:07 PM, Aron Bierbaum wrote:
>
>> I could be wrong, but I thought that the new API was thread safe only
>> if you used the _r versions of the method so that you can pass in a
>> handle to the thread specific data. For example you can look at:
>> badthreadtest.c and threadtest.c I was under the impression that the
>> old API could be used in order to not break backwards compatibility.
>> In order to accomplish this though, they use a global handle that gets
>> initialized in initGEOS().
>>
>> // NOTE: SRID will have to be changed after geometry creation
>> GEOSContextHandle_t handle = NULL;
>>
>> If I am correct in order to use the thread safe API you would have to
>> create a new handle for each thread and pass it to the new _r versions
>> of all the methods. Am I missing something here? Is this done
>> automatically somehow?
>>
>> Thanks,
>> Aron
>>
>>
>> On Mon, Jan 26, 2009 at 2:26 PM, Sean Gillies <[email protected]>
>> wrote:
>>> Aron,
>>>
>>> The GEOS 3.1 C API *is* the new thread safe API, and I've encountered
>>> no problems with it yet. Shapely's tests pass. I encourage you to
>>> checkout the Shapely trunk and try it. If you're interested, I could
>>> introduce you to the zc.buildout configuration I am using to make
>>> python, GEOS, and shapely development environments.
>>>
>>> Cheers,
>>> Sean
>>>
>>> On Jan 26, 2009, at 1:17 PM, Aron Bierbaum wrote:
>>>
>>>> Has there been any work/testing to get Shapely to work with the new
>>>> thread safe GEOS API?
>>>>
>>>> http://trac.osgeo.org/geos/wiki/RFC3
>>>> http://trac.osgeo.org/geos/ticket/210
>>>> http://trac.osgeo.org/geos/changeset/2232
>>>>
>>>> I would be very interested in testing any changes that have been
>>>> made
>>>> to support this.
>>>>
>>>> Thanks,
>>>> Aron
>>>> _______________________________________________
>>>> Community mailing list
>>>> [email protected]
>>>> http://lists.gispython.org/mailman/listinfo/community
>>>
>>>
>>>
>>> --
>>> Sean Gillies
>>> [email protected]
>>> http://sgillies.net
>>>
>>> _______________________________________________
>>> Community mailing list
>>> [email protected]
>>> http://lists.gispython.org/mailman/listinfo/community
>>>
>> _______________________________________________
>> Community mailing list
>> [email protected]
>> http://lists.gispython.org/mailman/listinfo/community
>
>
>
> --
> Sean Gillies
> [email protected]
> http://sgillies.net
>
> _______________________________________________
> Community mailing list
> [email protected]
> http://lists.gispython.org/mailman/listinfo/community
>
_______________________________________________
Community mailing list
[email protected]
http://lists.gispython.org/mailman/listinfo/community

Reply via email to