summaryrefslogtreecommitdiff
path: root/Modules/_multiprocessing
diff options
context:
space:
mode:
authorJesse Noller <jnoller@gmail.com>2009-04-02 04:22:09 +0000
committerJesse Noller <jnoller@gmail.com>2009-04-02 04:22:09 +0000
commit6ea0aa3c13921fc1f973283770926b89f0cdec51 (patch)
tree2a20bf332a0f01b3c3c8081e0f01c35985d88701 /Modules/_multiprocessing
parent545de9a29ad9e127b86d91b0a1b8e4e8ad09848b (diff)
downloadcpython-6ea0aa3c13921fc1f973283770926b89f0cdec51.tar.gz
Issue 3551: Raise ValueError if the size causes ERROR_NO_SYSTEM_RESOURCES
Diffstat (limited to 'Modules/_multiprocessing')
-rw-r--r--Modules/_multiprocessing/connection.h8
-rw-r--r--Modules/_multiprocessing/pipe_connection.c6
2 files changed, 12 insertions, 2 deletions
diff --git a/Modules/_multiprocessing/connection.h b/Modules/_multiprocessing/connection.h
index 458d1d3cf3..c2f85635ad 100644
--- a/Modules/_multiprocessing/connection.h
+++ b/Modules/_multiprocessing/connection.h
@@ -131,8 +131,12 @@ connection_sendbytes(ConnectionObject *self, PyObject *args)
res = conn_send_string(self, buffer + offset, size);
- if (res < 0)
- return mp_SetError(PyExc_IOError, res);
+ if (res < 0) {
+ if (PyErr_Occurred())
+ return NULL;
+ else
+ return mp_SetError(PyExc_IOError, res);
+ }
Py_RETURN_NONE;
}
diff --git a/Modules/_multiprocessing/pipe_connection.c b/Modules/_multiprocessing/pipe_connection.c
index 27e79dda7d..66947c838f 100644
--- a/Modules/_multiprocessing/pipe_connection.c
+++ b/Modules/_multiprocessing/pipe_connection.c
@@ -23,6 +23,12 @@ conn_send_string(ConnectionObject *conn, char *string, size_t length)
Py_BEGIN_ALLOW_THREADS
ret = WriteFile(conn->handle, string, length, &amount_written, NULL);
Py_END_ALLOW_THREADS
+
+ if (ret == 0 && GetLastError() == ERROR_NO_SYSTEM_RESOURCES) {
+ PyErr_Format(PyExc_ValueError, "Cannnot send %" PY_FORMAT_SIZE_T "d bytes over connection", length);
+ return MP_STANDARD_ERROR;
+ }
+
return ret ? MP_SUCCESS : MP_STANDARD_ERROR;
}