]> granicus.if.org Git - python/commitdiff
Issue #3846: Release GIL during calls to sqlite3_prepare. This improves concurrent...
authorGerhard Häring <gh@ghaering.de>
Fri, 12 Sep 2008 22:33:22 +0000 (22:33 +0000)
committerGerhard Häring <gh@ghaering.de>
Fri, 12 Sep 2008 22:33:22 +0000 (22:33 +0000)
Misc/NEWS
Modules/_sqlite/cursor.c
Modules/_sqlite/statement.c

index aca06f2a5bd7537f86c6e833d9ae36e53ac94806..a31bcd5f44965797ad8b5af89f23388ce15b5db6 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -151,6 +151,10 @@ Extension Modules
 - Issue #3103: Reduced globals symbols used by sqlite3 module and made sure all
   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
 -----
 
index 1bf27d7901e0c2a75ca73a833885014685b40d63..6572a559a655a7b4daf3dd369f6834d33cff9977 100644 (file)
@@ -790,11 +790,13 @@ PyObject* pysqlite_cursor_executescript(pysqlite_Cursor* self, PyObject* args)
         }
         statement_completed = 1;
 
+        Py_BEGIN_ALLOW_THREADS
         rc = sqlite3_prepare(self->connection->db,
                              script_cstr,
                              -1,
                              &statement,
                              &script_cstr);
+        Py_END_ALLOW_THREADS
         if (rc != SQLITE_OK) {
             _pysqlite_seterror(self->connection->db, NULL);
             goto error;
index dae83d4586eb904f9efd0fbef41c8fb7e2d83cf3..f200c56399179e0fc29e8d0f9f63f9698b238e3a 100644 (file)
@@ -79,11 +79,13 @@ int pysqlite_statement_create(pysqlite_Statement* self, pysqlite_Connection* con
 
     sql_cstr = PyString_AsString(sql_str);
 
+    Py_BEGIN_ALLOW_THREADS
     rc = sqlite3_prepare(connection->db,
                          sql_cstr,
                          -1,
                          &self->st,
                          &tail);
+    Py_END_ALLOW_THREADS
 
     self->db = connection->db;
 
@@ -328,11 +330,13 @@ int pysqlite_statement_recompile(pysqlite_Statement* self, PyObject* params)
 
     sql_cstr = PyString_AsString(self->sql);
 
+    Py_BEGIN_ALLOW_THREADS
     rc = sqlite3_prepare(self->db,
                          sql_cstr,
                          -1,
                          &new_st,
                          &tail);
+    Py_END_ALLOW_THREADS
 
     if (rc == SQLITE_OK) {
         /* The efficient sqlite3_transfer_bindings is only available in SQLite