Skip to content

Commit 3d6b8c9

Browse files
authored
Release GIL during result.discard() (#604)
1 parent 3517eb7 commit 3d6b8c9

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/MySQLdb/_mysql.c

+6-9
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,6 @@ _mysql_ConnectionObject_Initialize(
487487
PyErr_SetNone(PyExc_MemoryError);
488488
return -1;
489489
}
490-
Py_BEGIN_ALLOW_THREADS ;
491490
self->open = 1;
492491

493492
if (connect_timeout) {
@@ -548,10 +547,10 @@ _mysql_ConnectionObject_Initialize(
548547
mysql_options(&(self->connection), MYSQL_DEFAULT_AUTH, auth_plugin);
549548
}
550549

550+
Py_BEGIN_ALLOW_THREADS
551551
conn = mysql_real_connect(&(self->connection), host, user, passwd, db,
552552
port, unix_socket, client_flag);
553-
554-
Py_END_ALLOW_THREADS ;
553+
Py_END_ALLOW_THREADS
555554

556555
if (ssl) {
557556
int i;
@@ -1403,9 +1402,9 @@ _mysql__fetch_row(
14031402
if (!self->use)
14041403
row = mysql_fetch_row(self->result);
14051404
else {
1406-
Py_BEGIN_ALLOW_THREADS;
1405+
Py_BEGIN_ALLOW_THREADS
14071406
row = mysql_fetch_row(self->result);
1408-
Py_END_ALLOW_THREADS;
1407+
Py_END_ALLOW_THREADS
14091408
}
14101409
if (!row && mysql_errno(&(((_mysql_ConnectionObject *)(self->conn))->connection))) {
14111410
_mysql_Exception((_mysql_ConnectionObject *)self->conn);
@@ -1495,9 +1494,11 @@ _mysql_ResultObject_discard(
14951494
check_result_connection(self);
14961495

14971496
MYSQL_ROW row;
1497+
Py_BEGIN_ALLOW_THREADS
14981498
while (NULL != (row = mysql_fetch_row(self->result))) {
14991499
// do nothing
15001500
}
1501+
Py_END_ALLOW_THREADS
15011502
if (mysql_errno(self->conn)) {
15021503
return _mysql_Exception(self->conn);
15031504
}
@@ -1747,9 +1748,7 @@ _mysql_ConnectionObject_insert_id(
17471748
{
17481749
my_ulonglong r;
17491750
check_connection(self);
1750-
Py_BEGIN_ALLOW_THREADS
17511751
r = mysql_insert_id(&(self->connection));
1752-
Py_END_ALLOW_THREADS
17531752
return PyLong_FromUnsignedLongLong(r);
17541753
}
17551754

@@ -2058,9 +2057,7 @@ _mysql_ConnectionObject_thread_id(
20582057
{
20592058
unsigned long pid;
20602059
check_connection(self);
2061-
Py_BEGIN_ALLOW_THREADS
20622060
pid = mysql_thread_id(&(self->connection));
2063-
Py_END_ALLOW_THREADS
20642061
return PyLong_FromLong((long)pid);
20652062
}
20662063

0 commit comments

Comments
 (0)