MCPcopy Create free account
hub / github.com/Distributive-Network/PythonMonkey / _enqueueWithDelay

Function _enqueueWithDelay

src/PyEventLoop.cc:80–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78}
79
80static PyObject *_enqueueWithDelay(PyObject *_loop, PyEventLoop::AsyncHandle::id_t handleId, PyObject *jobFn, double delaySeconds, bool repeat) {
81 PyObject *wrapper = PyCFunction_New(&timerJobWrapperDef, jobFn);
82 // Schedule job to the Python event-loop
83 // https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.loop.call_later
84 PyObject *asyncHandle = PyObject_CallMethod(_loop, "call_later", "dOOIdb", delaySeconds, wrapper, _loop, handleId, delaySeconds, repeat); // https://docs.python.org/3/c-api/arg.html#c.Py_BuildValue
85 if (!asyncHandle) {
86 return nullptr; // RuntimeError
87 }
88
89 auto handle = PyEventLoop::AsyncHandle::fromId(handleId);
90 Py_XDECREF(handle->swap(asyncHandle));
91
92 return asyncHandle;
93}
94
95PyEventLoop::AsyncHandle::id_t PyEventLoop::enqueueWithDelay(PyObject *jobFn, double delaySeconds, bool repeat) {
96 auto handleId = PyEventLoop::AsyncHandle::newEmpty();

Callers 2

timerJobWrapperFunction · 0.85
enqueueWithDelayMethod · 0.85

Calls 1

swapMethod · 0.80

Tested by

no test coverage detected