-
Notifications
You must be signed in to change notification settings - Fork 124
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
Multithreading #53
Comments
+1 |
Actually seems it is not possible. At least with recent versions. |
libspatialindex is not threadsafe and Rtree does not do thread safety. It is something that could be done, but it would take a lot of meticulous work to achieve. |
Ok I can comprehend that concurrent writing and reading may cause problems, but are read-only accesses safe? |
In my experience it seems it is not. |
That's strange because I am accessing one rtree from multiple threads (only read), and so far i did not encounter any problems. |
@christophlingg Race conditions can be like that. It may be that certain issues are only triggered under high(er) loads. |
No. libspatialindex, especially as used through the C API like Rtree does, is not thread safe. If it is working for you, it is most likely due to luck. |
Now I know I need to fix something ;-) Thanks to your feedback I can do this before it crashes! |
The most pressing issue is probably the one described in libspatialindex/libspatialindex#71 especially in regards to the C API. If you put some aggressive locking around things in python land, you are likely to be reasonably protected. The issues most likely manifest themselves in regard to error messages, and the error stack of the C API of libspatialindex not being protected in any way. |
I'm working with a single thread instance of the index, but it daily crashes! |
Protect any access you do to libspatialindex with a mutex and lock accordingly. |
@hobu :Adding mutex or lock did not work for me. Moreover, also using different processes working on the same index file ends up in segmentation fault. |
libspatialindex has a thread safety issue. Someone needs to develop a clear case that demonstrates the issue so it can be resolved. |
Thanks for providing RTree for Python!
I was wondering if rtree can be used in a multithreaded context?
The text was updated successfully, but these errors were encountered: