search for: py_callback

Displaying 6 results from an estimated 6 matches for "py_callback".

2019 Nov 18
0
[PATCH] Python: Fix GIL usage in guestfs_int_py_event_callback_wrapper (RHBZ#1773520)
...7 @@ guestfs_int_py_event_callback_wrapper (guestfs_h *g, const char *buf, size_t buf_len, const uint64_t *array, size_t array_len) { - PyGILState_STATE py_save = PyGILState_UNLOCKED; + PyGILState_STATE py_save; PyObject *py_callback = callback; PyObject *py_array; PyObject *args; PyObject *a; size_t i; PyObject *py_r; + int threads_initialized = PyEval_ThreadsInitialized (); + + if (threads_initialized) + py_save = PyGILState_Ensure (); py_array = PyList_New (array_len); for (i = 0; i < array_len...
2019 Jan 22
3
[PATCH v2 0/2] python: fixes for Python 3
A couple of fixes for Python 3 to the Python binding. Unfortunately a behaviour change is needed, although it fixes broken types used. Changes from v1: - handle also FBuffer in structs Pino Toscano (2): python: fix call of Python handlers of events python: change types for RBufferOut/FBuffer with Python 3 (RHBZ#1661871) generator/python.ml | 9 +++++++++ python/handle.c | 3 ++- 2
2019 Jan 22
3
[PATCH 0/2] python: fixes for Python 3
A couple of fixes for Python 3 to the Python binding. Unfortunately a behaviour change is needed, although it fixes broken types used. Pino Toscano (2): python: fix call of Python handlers of events python: change return type for RBufferOut with Python 3 (RHBZ#1661871) generator/python.ml | 4 ++++ python/handle.c | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) -- 2.20.1
2023 Feb 14
2
[PATCH 1/2] python: Avoid crash if callback parameters cannot be built
...stfs_h *g, args = Py_BuildValue ("(Kis#O)", (unsigned PY_LONG_LONG) event, event_handle, buf, buf_len, py_array); + if (args == NULL) { + PyErr_PrintEx (0); + goto out; + } + Py_INCREF (args); - py_r = PyObject_CallObject (py_callback, args); - Py_DECREF (args); - if (py_r != NULL) Py_DECREF (py_r); else /* Callback threw an exception: print it. */ PyErr_PrintEx (0); + out: PyGILState_Release (py_save); } -- 2.39.0
2023 Feb 17
2
[PATCH v3 0/2] python: Avoid leaking py_array and py_args in event callbacks
Version 1 was here: https://listman.redhat.com/archives/libguestfs/2023-February/030732.html (Ignore version 2 which had a mistake, this is version 3) Following Eric's suggestion here: https://listman.redhat.com/archives/libguestfs/2023-February/030746.html let's decrement the reference of py_array right after adding it to the args. (This works even if args fails to be built).
2023 Feb 17
1
[PATCH 1/2] python: Avoid crash if callback parameters cannot be built
...nt here on the error path makes sense. However, on success, it means py_array now has a refcount of 2, and args has a refcount of 1 (where cleaning up args will reduce only 1 of the refs to py_array)... > > + > > Py_INCREF (args); > > - > > py_r = PyObject_CallObject (py_callback, args); > > - > > Py_DECREF (args); This temporary increment/decrement of args around PyObject_CallObject is a safety factor to ensure that the call itself doesn't try to reclaim args while still in use. I'm not sure if it is strictly required, but it doesn't hurt. At...