Release GIL during result.discard() (#604)

This commit is contained in:
Inada Naoki
2023-05-18 17:19:10 +09:00
committed by GitHub
parent 3517eb77b7
commit 3d6b8c9b7c

View File

@ -487,7 +487,6 @@ _mysql_ConnectionObject_Initialize(
PyErr_SetNone(PyExc_MemoryError); PyErr_SetNone(PyExc_MemoryError);
return -1; return -1;
} }
Py_BEGIN_ALLOW_THREADS ;
self->open = 1; self->open = 1;
if (connect_timeout) { if (connect_timeout) {
@ -548,10 +547,10 @@ _mysql_ConnectionObject_Initialize(
mysql_options(&(self->connection), MYSQL_DEFAULT_AUTH, auth_plugin); mysql_options(&(self->connection), MYSQL_DEFAULT_AUTH, auth_plugin);
} }
Py_BEGIN_ALLOW_THREADS
conn = mysql_real_connect(&(self->connection), host, user, passwd, db, conn = mysql_real_connect(&(self->connection), host, user, passwd, db,
port, unix_socket, client_flag); port, unix_socket, client_flag);
Py_END_ALLOW_THREADS
Py_END_ALLOW_THREADS ;
if (ssl) { if (ssl) {
int i; int i;
@ -1403,9 +1402,9 @@ _mysql__fetch_row(
if (!self->use) if (!self->use)
row = mysql_fetch_row(self->result); row = mysql_fetch_row(self->result);
else { else {
Py_BEGIN_ALLOW_THREADS; Py_BEGIN_ALLOW_THREADS
row = mysql_fetch_row(self->result); row = mysql_fetch_row(self->result);
Py_END_ALLOW_THREADS; Py_END_ALLOW_THREADS
} }
if (!row && mysql_errno(&(((_mysql_ConnectionObject *)(self->conn))->connection))) { if (!row && mysql_errno(&(((_mysql_ConnectionObject *)(self->conn))->connection))) {
_mysql_Exception((_mysql_ConnectionObject *)self->conn); _mysql_Exception((_mysql_ConnectionObject *)self->conn);
@ -1495,9 +1494,11 @@ _mysql_ResultObject_discard(
check_result_connection(self); check_result_connection(self);
MYSQL_ROW row; MYSQL_ROW row;
Py_BEGIN_ALLOW_THREADS
while (NULL != (row = mysql_fetch_row(self->result))) { while (NULL != (row = mysql_fetch_row(self->result))) {
// do nothing // do nothing
} }
Py_END_ALLOW_THREADS
if (mysql_errno(self->conn)) { if (mysql_errno(self->conn)) {
return _mysql_Exception(self->conn); return _mysql_Exception(self->conn);
} }
@ -1747,9 +1748,7 @@ _mysql_ConnectionObject_insert_id(
{ {
my_ulonglong r; my_ulonglong r;
check_connection(self); check_connection(self);
Py_BEGIN_ALLOW_THREADS
r = mysql_insert_id(&(self->connection)); r = mysql_insert_id(&(self->connection));
Py_END_ALLOW_THREADS
return PyLong_FromUnsignedLongLong(r); return PyLong_FromUnsignedLongLong(r);
} }
@ -2058,9 +2057,7 @@ _mysql_ConnectionObject_thread_id(
{ {
unsigned long pid; unsigned long pid;
check_connection(self); check_connection(self);
Py_BEGIN_ALLOW_THREADS
pid = mysql_thread_id(&(self->connection)); pid = mysql_thread_id(&(self->connection));
Py_END_ALLOW_THREADS
return PyLong_FromLong((long)pid); return PyLong_FromLong((long)pid);
} }