| 78 | } |
| 79 | |
| 80 | static 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 | |
| 95 | PyEventLoop::AsyncHandle::id_t PyEventLoop::enqueueWithDelay(PyObject *jobFn, double delaySeconds, bool repeat) { |
| 96 | auto handleId = PyEventLoop::AsyncHandle::newEmpty(); |
no test coverage detected