sqlite3 module and thread-safe SQLite library

We ran into an issue where having the SQLite library built with -DSQLITE_THREADSAFE=0, but then the sqlite3 module (really, the _sqlite3.so0 crashing in threading code. So I have to ask if it is intended that the sqlite3 Python module always be built with a thread safe SQLite library. Thanks, Tom

On Tue, Dec 17, 2019 at 12:30 PM Kacvinsky, Tom <Tom.Kacvinsky@vector.com> wrote:
We ran into an issue where having the SQLite library built with -DSQLITE_THREADSAFE=0, but then the sqlite3 module (really, the _sqlite3.so0 crashing in threading code. So I have to ask if it is intended that the sqlite3 Python module always be built with a thread safe SQLite library.
Thanks,
Tom
Given your experience I think you've answered the question: Yes. But it would be good if we could detect this at build time (is there a way to do that?) and prevent the module from being built against the sqlite3 library compiled in this unusual mode. Threading support is required in order to be a valid CPython platform, so all libraries used should be aware of that. -gps
_______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-leave@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/PKHFTUQS... Code of Conduct: http://python.org/psf/codeofconduct/

On 18/12/2019 00.56, Gregory P. Smith wrote:
On Tue, Dec 17, 2019 at 12:30 PM Kacvinsky, Tom <Tom.Kacvinsky@vector..com <mailto:Tom.Kacvinsky@vector.com>> wrote:
We ran into an issue where having the SQLite library built with -DSQLITE_THREADSAFE=0, but then the sqlite3 module (really, the _sqlite3.so0 crashing in threading code. So I have to ask if it is intended that the sqlite3 Python module always be built with a thread safe SQLite library.
Thanks,
Tom
Given your experience I think you've answered the question: Yes. But it would be good if we could detect this at build time (is there a way to do that?) and prevent the module from being built against the sqlite3 library compiled in this unusual mode.. Threading support is required in order to be a valid CPython platform, so all libraries used should be aware of that.
We have to detect the problem at run-time. Compile time is not sufficient. It's possible to compile Python with a thread-safe version of libsqlite3, then run Python with a unsafe version of libsqlite3. sqlite3 has two APIs to query thread safety and three different settings for threading: sqlite3_threadsafe() sqlite3_config() SQLITE_CONFIG_SINGLETHREAD SQLITE_CONFIG_MULTITHREAD SQLITE_CONFIG_SERIALIZED Only serialized is fully thread safe. I would start by checking that (sqlite3_threadsafe() == SQLITE_CONFIG_SERIALIZED). Christian
participants (3)
-
Christian Heimes
-
Gregory P. Smith
-
Kacvinsky, Tom