Skip to content

Commit e38b4af

Browse files
Release the Python GIL while enqueuing and dequeuing messages!
1 parent df56c7f commit e38b4af

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/cxoConnection.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,9 +1469,11 @@ static PyObject *cxoConnection_dequeue(cxoConnection *conn, PyObject* args,
14691469
return NULL;
14701470

14711471
// dequeue payload
1472+
Py_BEGIN_ALLOW_THREADS
14721473
status = dpiConn_deqObject(conn->handle, nameBuffer.ptr, nameBuffer.size,
14731474
optionsObj->handle, propertiesObj->handle, payloadObj->handle,
14741475
&messageIdValue, &messageIdLength);
1476+
Py_END_ALLOW_THREADS
14751477
cxoBuffer_clear(&nameBuffer);
14761478
if (status < 0)
14771479
return cxoError_raiseAndReturnNull();
@@ -1512,9 +1514,11 @@ static PyObject *cxoConnection_enqueue(cxoConnection *conn, PyObject* args,
15121514
return NULL;
15131515

15141516
// enqueue payload
1517+
Py_BEGIN_ALLOW_THREADS
15151518
status = dpiConn_enqObject(conn->handle, nameBuffer.ptr, nameBuffer.size,
15161519
optionsObj->handle, propertiesObj->handle, payloadObj->handle,
15171520
&messageIdValue, &messageIdLength);
1521+
Py_END_ALLOW_THREADS
15181522
cxoBuffer_clear(&nameBuffer);
15191523
if (status < 0)
15201524
return cxoError_raiseAndReturnNull();

src/cxoQueue.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,15 +192,18 @@ int cxoQueue_deqHelper(cxoQueue *queue, uint32_t *numProps,
192192
const char *buffer;
193193
cxoMsgProps *temp;
194194
cxoObject *obj;
195-
int ok;
195+
int ok, status;
196196

197197
// use the same array to store the intermediate values provided by ODPI-C;
198198
// by doing so there is no need to allocate an additional array and any
199199
// values created by this helper routine are cleaned up on error
200200
handles = (dpiMsgProps**) props;
201201

202202
// perform dequeue
203-
if (dpiQueue_deqMany(queue->handle, numProps, handles) < 0)
203+
Py_BEGIN_ALLOW_THREADS
204+
status = dpiQueue_deqMany(queue->handle, numProps, handles);
205+
Py_END_ALLOW_THREADS
206+
if (status < 0)
204207
return cxoError_raiseAndReturnInt();
205208

206209
// create objects that are returned to the user
@@ -298,7 +301,10 @@ int cxoQueue_enqHelper(cxoQueue *queue, uint32_t numProps,
298301
}
299302

300303
// perform enqueue
301-
if (dpiQueue_enqMany(queue->handle, numProps, handles) < 0)
304+
Py_BEGIN_ALLOW_THREADS
305+
status = dpiQueue_enqMany(queue->handle, numProps, handles);
306+
Py_END_ALLOW_THREADS
307+
if (status < 0)
302308
return cxoError_raiseAndReturnInt();
303309

304310
return 0;

0 commit comments

Comments
 (0)