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

Function sendJobToMainLoop

src/JobQueue.cc:114–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112}
113
114bool sendJobToMainLoop(PyObject *pyFunc) {
115 PyGILState_STATE gstate = PyGILState_Ensure();
116
117 // Send job to the running Python event-loop on cx's thread (the main thread)
118 PyEventLoop loop = PyEventLoop::getMainLoop();
119 if (!loop.initialized()) {
120 PyGILState_Release(gstate);
121 return false;
122 }
123 loop.enqueue(pyFunc);
124
125 loop._loop = nullptr; // the `Py_XDECREF` Python API call in `PyEventLoop`'s destructor will not be accessible once we hand over the GIL by `PyGILState_Release`
126 PyGILState_Release(gstate);
127 return true;
128}
129
130void JobQueue::promiseRejectionTracker(JSContext *cx,
131 bool mutedErrors,

Callers

nothing calls this directly

Calls 2

initializedMethod · 0.80
enqueueMethod · 0.80

Tested by

no test coverage detected