Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Convert _interpqueues.put()
  • Loading branch information
AA-Turner committed Aug 12, 2025
commit 4432216191dfff652067f99f2e2b1ff5affcbb6b
37 changes: 16 additions & 21 deletions Modules/_interpqueuesmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1610,25 +1610,26 @@ _interpqueues_list_all_impl(PyObject *module)
return ids;
}

/*[clinic input]
_interpqueues.put
qid as qidarg: qidarg
obj: object
unboundop as unboundarg: int = -1
fallback as fallbackarg: int = -1

Add the object's data to the queue.
[clinic start generated code]*/

static PyObject *
queuesmod_put(PyObject *self, PyObject *args, PyObject *kwds)
_interpqueues_put_impl(PyObject *module, qidarg_converter_data qidarg,
PyObject *obj, int unboundarg, int fallbackarg)
/*[clinic end generated code: output=24c24c63489a19fa input=5cdee664acd659ce]*/
{
static char *kwlist[] = {"qid", "obj", "unboundop", "fallback", NULL};
qidarg_converter_data qidarg = {0};
PyObject *obj;
int unboundarg = -1;
int fallbackarg = -1;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&O|ii$p:put", kwlist,
Comment thread
AA-Turner marked this conversation as resolved.
Outdated
qidarg_converter, &qidarg, &obj,
&unboundarg, &fallbackarg))
{
return NULL;
}
int64_t qid = qidarg.id;
struct _queuedefaults defaults = {-1, -1};
if (unboundarg < 0 || fallbackarg < 0) {
int err = queue_get_defaults(&_globals.queues, qid, &defaults);
if (handle_queue_error(err, self, qid)) {
if (handle_queue_error(err, module, qid)) {
return NULL;
}
}
Expand All @@ -1644,18 +1645,13 @@ queuesmod_put(PyObject *self, PyObject *args, PyObject *kwds)
/* Queue up the object. */
int err = queue_put(&_globals.queues, qid, obj, unboundop, fallback);
// This is the only place that raises QueueFull.
if (handle_queue_error(err, self, qid)) {
if (handle_queue_error(err, module, qid)) {
return NULL;
}

Py_RETURN_NONE;
}

PyDoc_STRVAR(queuesmod_put_doc,
"put(qid, obj)\n\
\n\
Add the object's data to the queue.");

static PyObject *
queuesmod_get(PyObject *self, PyObject *args, PyObject *kwds)
{
Expand Down Expand Up @@ -1900,8 +1896,7 @@ static PyMethodDef module_functions[] = {
_INTERPQUEUES_CREATE_METHODDEF
_INTERPQUEUES_DESTROY_METHODDEF
_INTERPQUEUES_LIST_ALL_METHODDEF
{"put", _PyCFunction_CAST(queuesmod_put),
METH_VARARGS | METH_KEYWORDS, queuesmod_put_doc},
_INTERPQUEUES_PUT_METHODDEF
{"get", _PyCFunction_CAST(queuesmod_get),
METH_VARARGS | METH_KEYWORDS, queuesmod_get_doc},
{"bind", _PyCFunction_CAST(queuesmod_bind),
Expand Down
85 changes: 84 additions & 1 deletion Modules/clinic/_interpqueuesmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.