diff options
Diffstat (limited to 'Modules/_multiprocessing/pipe_connection.c')
| -rw-r--r-- | Modules/_multiprocessing/pipe_connection.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/Modules/_multiprocessing/pipe_connection.c b/Modules/_multiprocessing/pipe_connection.c index 1592cca..d655c50 100644 --- a/Modules/_multiprocessing/pipe_connection.c +++ b/Modules/_multiprocessing/pipe_connection.c @@ -18,9 +18,12 @@ static Py_ssize_t conn_send_string(ConnectionObject *conn, char *string, size_t length) { DWORD amount_written; + BOOL ret; - return WriteFile(conn->handle, string, length, &amount_written, NULL) - ? MP_SUCCESS : MP_STANDARD_ERROR; + Py_BEGIN_ALLOW_THREADS + ret = WriteFile(conn->handle, string, length, &amount_written, NULL); + Py_END_ALLOW_THREADS + return ret ? MP_SUCCESS : MP_STANDARD_ERROR; } /* @@ -34,11 +37,14 @@ conn_recv_string(ConnectionObject *conn, char *buffer, size_t buflength, char **newbuffer, size_t maxlength) { DWORD left, length, full_length, err; - + BOOL ret; *newbuffer = NULL; - if (ReadFile(conn->handle, buffer, MIN(buflength, maxlength), - &length, NULL)) + Py_BEGIN_ALLOW_THREADS + ret = ReadFile(conn->handle, buffer, MIN(buflength, maxlength), + &length, NULL); + Py_END_ALLOW_THREADS + if (ret) return length; err = GetLastError(); @@ -61,7 +67,10 @@ conn_recv_string(ConnectionObject *conn, char *buffer, memcpy(*newbuffer, buffer, length); - if (ReadFile(conn->handle, *newbuffer+length, left, &length, NULL)) { + Py_BEGIN_ALLOW_THREADS + ret = ReadFile(conn->handle, *newbuffer+length, left, &length, NULL) + Py_END_ALLOW_THREADS + if (ret) { assert(length == left); return full_length; } else { |
