Issue #3846: Release GIL during calls to sqlite3_prepare. This improves concurrent access to the same database file from multiple threads/processes.

This commit is contained in:
Gerhard Häring 2008-09-12 22:33:22 +00:00
parent 6e1afcf988
commit e6872eb417
3 changed files with 10 additions and 0 deletions

View File

@ -151,6 +151,10 @@ Extension Modules
- Issue #3103: Reduced globals symbols used by sqlite3 module and made sure all - Issue #3103: Reduced globals symbols used by sqlite3 module and made sure all
remaining ones have "pysqlite_" prefix. remaining ones have "pysqlite_" prefix.
- Issue #3846: Release the GIL during sqlite3_prepare calls. This improves
concurrent access to the same SQLite database from multiple
threads/processes.
Tests Tests
----- -----

View File

@ -790,11 +790,13 @@ PyObject* pysqlite_cursor_executescript(pysqlite_Cursor* self, PyObject* args)
} }
statement_completed = 1; statement_completed = 1;
Py_BEGIN_ALLOW_THREADS
rc = sqlite3_prepare(self->connection->db, rc = sqlite3_prepare(self->connection->db,
script_cstr, script_cstr,
-1, -1,
&statement, &statement,
&script_cstr); &script_cstr);
Py_END_ALLOW_THREADS
if (rc != SQLITE_OK) { if (rc != SQLITE_OK) {
_pysqlite_seterror(self->connection->db, NULL); _pysqlite_seterror(self->connection->db, NULL);
goto error; goto error;

View File

@ -79,11 +79,13 @@ int pysqlite_statement_create(pysqlite_Statement* self, pysqlite_Connection* con
sql_cstr = PyString_AsString(sql_str); sql_cstr = PyString_AsString(sql_str);
Py_BEGIN_ALLOW_THREADS
rc = sqlite3_prepare(connection->db, rc = sqlite3_prepare(connection->db,
sql_cstr, sql_cstr,
-1, -1,
&self->st, &self->st,
&tail); &tail);
Py_END_ALLOW_THREADS
self->db = connection->db; self->db = connection->db;
@ -328,11 +330,13 @@ int pysqlite_statement_recompile(pysqlite_Statement* self, PyObject* params)
sql_cstr = PyString_AsString(self->sql); sql_cstr = PyString_AsString(self->sql);
Py_BEGIN_ALLOW_THREADS
rc = sqlite3_prepare(self->db, rc = sqlite3_prepare(self->db,
sql_cstr, sql_cstr,
-1, -1,
&new_st, &new_st,
&tail); &tail);
Py_END_ALLOW_THREADS
if (rc == SQLITE_OK) { if (rc == SQLITE_OK) {
/* The efficient sqlite3_transfer_bindings is only available in SQLite /* The efficient sqlite3_transfer_bindings is only available in SQLite