mirror of
https://github.com/python/cpython.git
synced 2025-08-31 22:18:28 +00:00
gh-84570: Add Timeouts to SendChannel.send() and RecvChannel.recv() (gh-110567)
This commit is contained in:
parent
7029c1a1c5
commit
c58c63fdf6
8 changed files with 205 additions and 50 deletions
|
@ -88,14 +88,15 @@ lock_acquire_parse_args(PyObject *args, PyObject *kwds,
|
|||
char *kwlist[] = {"blocking", "timeout", NULL};
|
||||
int blocking = 1;
|
||||
PyObject *timeout_obj = NULL;
|
||||
const _PyTime_t unset_timeout = _PyTime_FromSeconds(-1);
|
||||
|
||||
*timeout = unset_timeout ;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|pO:acquire", kwlist,
|
||||
&blocking, &timeout_obj))
|
||||
return -1;
|
||||
|
||||
// XXX Use PyThread_ParseTimeoutArg().
|
||||
|
||||
const _PyTime_t unset_timeout = _PyTime_FromSeconds(-1);
|
||||
*timeout = unset_timeout;
|
||||
|
||||
if (timeout_obj
|
||||
&& _PyTime_FromSecondsObject(timeout,
|
||||
timeout_obj, _PyTime_ROUND_TIMEOUT) < 0)
|
||||
|
@ -108,7 +109,7 @@ lock_acquire_parse_args(PyObject *args, PyObject *kwds,
|
|||
}
|
||||
if (*timeout < 0 && *timeout != unset_timeout) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"timeout value must be positive");
|
||||
"timeout value must be a non-negative number");
|
||||
return -1;
|
||||
}
|
||||
if (!blocking)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue