Displaying 20 results from an estimated 32 matches for "py_sav".
Did you mean:
py_save
2019 Nov 18
0
[PATCH] Python: Fix GIL usage in guestfs_int_py_event_callback_wrapper (RHBZ#1773520)
...5b06 100644
--- a/python/handle.c
+++ b/python/handle.c
@@ -112,13 +112,17 @@ 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_Ensu...
2019 Aug 13
0
[PATCH libnbd 2/6] generator: Create only one Python wrapper per closure.
..."static int\n";
+ pr "%s_wrapper " cbname;
+ C.print_cbarg_list cbargs;
+ pr "\n";
+ pr "{\n";
+ pr " int ret = 0;\n";
+ pr "\n";
+ pr " if (valid_flag & LIBNBD_CALLBACK_VALID) {\n";
+ pr " PyGILState_STATE py_save = PyGILState_UNLOCKED;\n";
+ pr " PyObject *py_args, *py_ret;\n";
+ List.iter (
+ function
+ | CBArrayAndLen (UInt32 n, len) ->
+ pr " PyObject *py_%s = PyList_New (%s);\n" n len;
+ pr " for (size_t i = 0; i < %s; ++i)\n" 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
...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
2019 Aug 14
5
[PATCH libnbd 0/3] Use free callback to hold ref to AIO buffer.
Basically the same as this patch series, but for Python:
https://www.redhat.com/archives/libguestfs/2019-August/msg00235.html
plus adding the 590 asynch test at the end.
Rich.
2019 Jul 16
0
[libnbd PATCH 2/2] RFC: generator: Handle shared callbacks in Python
...e
+ let print_callback cb =
+ pr "static int\n";
+ pr "%s_%s_wrapper " name cb.name;
+ print_c_arg_list ~handle:(Some "void *_data") cb.cbargs;
+ pr "\n";
+ pr "{\n";
+ pr " int ret;\n";
+ pr " PyGILState_STATE py_save = PyGILState_UNLOCKED;\n";
+ pr " PyObject *py_args, *py_ret;\n";
+ pr " struct %s_data *data = _data;\n" name;
+ List.iter (
+ function
+ | ArrayAndLen (UInt32 n, len) ->
+ pr " PyObject *py_%s = PyList_New (%s);\n" n len;
+...
2019 Aug 12
0
[PATCH libnbd 7/7] api: Remove the valid_flag from all callbacks.
...-4226,26 +4218,25 @@ let print_python_binding name { args; optargs; ret; may_set_error } =
pr "{\n";
pr " int ret = 0;\n";
pr "\n";
- pr " if (valid_flag & LIBNBD_CALLBACK_VALID) {\n";
- pr " PyGILState_STATE py_save = PyGILState_UNLOCKED;\n";
- pr " PyObject *py_args, *py_ret;\n";
+ pr " PyGILState_STATE py_save = PyGILState_UNLOCKED;\n";
+ pr " PyObject *py_args, *py_ret;\n";
List.iter (
function
| CBArrayAndLen (UInt32 n,...
2019 Jul 16
3
[RFC libnbd PATCH 0/2] Start fixing python nbd.pread_structured_callback
Posting now that I got something to compile (at the expense of
breaking OCaml bindings), but I'm open to ideas on how to improve it.
Eric Blake (2):
generator: Tweak print_c_arg_list to take alternate first arg
RFC: generator: Handle shared callbacks in Python
generator/generator | 556 ++++++++++++++++++++++----------------------
1 file changed, 280 insertions(+), 276 deletions(-)
--
2019 Aug 13
0
[PATCH libnbd 2/4] api: Add free function and remove valid_flag parameter.
...REATE 1\n";
pr "\n";
@@ -4032,26 +4025,25 @@ let print_python_closure_wrapper { cbname; cbargs } =
pr "{\n";
pr " int ret = 0;\n";
pr "\n";
- pr " if (valid_flag & LIBNBD_CALLBACK_VALID) {\n";
- pr " PyGILState_STATE py_save = PyGILState_UNLOCKED;\n";
- pr " PyObject *py_args, *py_ret;\n";
+ pr " PyGILState_STATE py_save = PyGILState_UNLOCKED;\n";
+ pr " PyObject *py_args, *py_ret;\n";
List.iter (
function
| CBArrayAndLen (UInt32 n, len) ->
- pr "...
2019 Jul 24
0
[PATCH libnbd v2 2/5] lib: Implement closure lifetimes.
...uot;;
pr "%s_%s_wrapper " name cbname;
- C.print_arg_list ~user_data:true cbargs;
+ C.print_arg_list ~valid_flag:true ~user_data:true cbargs;
pr "\n";
pr "{\n";
- pr " int ret;\n";
- pr " PyGILState_STATE py_save = PyGILState_UNLOCKED;\n";
- pr " PyObject *py_args, *py_ret;\n";
+ pr " int ret = 0;\n";
+ pr "\n";
+ pr " if (valid_flag & LIBNBD_CALLBACK_VALID) {\n";
+ pr " PyGILState_STATE py_save = PyGILState_UNLOCKED;...
2017 Mar 03
5
[PATCH v2 0/4] Avoid 0-bytes malloc in bindings
Hi,
some of the bindings may try to malloc with 0 bytes as size when closing
an handle, because there were no event handlers registered. Since this
can have different behaviours in POSIX, avoid that situation altogether
by just skipping allocating anything when there were no event handlers.
Thanks,
Pino Toscano (4):
ocaml: do not try to malloc 0 elements in get_all_event_callbacks
python:
2019 Jul 24
0
[PATCH libnbd 1/3] generator: Change Closure so it describes single callbacks.
...ack of %s. */\n" cbname name;
+ pr "static int\n";
+ pr "%s_%s_wrapper " name cbname;
+ C.print_arg_list ~user_data:true cbargs;
+ pr "\n";
+ pr "{\n";
+ pr " int ret;\n";
+ pr " PyGILState_STATE py_save = PyGILState_UNLOCKED;\n";
+ pr " PyObject *py_args, *py_ret;\n";
List.iter (
- fun { cbname; cbargs } ->
- pr "static int\n";
- pr "%s_%s_wrapper " name cbname;
- C.print_arg_list ~user_data:true cbargs;
-...
2019 Jul 24
8
[PATCH libnbd v2 0/5] lib: Implement closure lifetimes.
v1 was here:
https://www.redhat.com/archives/libguestfs/2019-July/thread.html#00231
The changes address everything that Eric picked up in his review of
the first two patches. I have also added two more patches (4 and 5)
which respectively fix docs and change int status -> unsigned status,
as discussed.
Passes make, check, check-valgrind.
Rich.
2019 Aug 13
12
[PATCH 0/6] Implement OClosure.
Patches 1-4 are basically uncontroversial, straightforward refactoring
and IMHO we should just push them. Possibly 1-3 should be squashed
together, but I posted them separately so they are easier to review.
Patches 5 and 6 together implement OClosure. Patch 5 adds the feature
and is simple to understand.
Patch 6 changes the Closure completion callbacks into OClosure, but
because it doesn't
2019 Jul 16
0
[PATCH libnbd v2] generator: Define new Closure type instead of callbacks.
...pr "};\n";
pr "\n";
- pr "static int\n";
- pr "%s_%s_wrapper " name cb_name;
- print_c_arg_list args;
- pr "\n";
- pr "{\n";
- pr " int ret;\n";
- pr " PyGILState_STATE py_save = PyGILState_UNLOCKED;\n";
- pr " PyObject *py_args, *py_ret;\n";
- List.iter (
- function
- | ArrayAndLen (UInt32 n, len) ->
- pr " PyObject *py_%s = PyList_New (%s);\n" n len;
- pr " for (size_t i = 0; i < %...
2019 Aug 14
0
[PATCH libnbd 2/3] python: Hold a refcount to persistent AIO buffer until command completion.
...pr " * callback. This is because we may need to unregister an\n";
+ pr " * associated persistent buffer.\n";
+ pr " */\n";
+ pr " if (data->fn == NULL)\n";
+ pr " return 0;\n";
+ pr "\n";
pr " PyGILState_STATE py_save = PyGILState_UNLOCKED;\n";
pr " PyObject *py_args, *py_ret;\n";
List.iter (
@@ -4253,10 +4260,24 @@ let print_python_binding name { args; optargs; ret; may_set_error } =
pr " }\n";
pr " }\n";
pr " else\n";
- pr...
2019 Jul 24
2
Re: [PATCH libnbd 2/3] lib: Implement closure lifetimes.
...;
> + C.print_arg_list ~valid_flag:true ~user_data:true cbargs;
> pr "\n";
> pr "{\n";
> + pr " if (valid_flag & LIBNBD_CALLBACK_VALID) {\n";
> pr " int ret;\n";
> pr " PyGILState_STATE py_save = PyGILState_UNLOCKED;\n";
Do we care about the generated indentation looking sane? (That can be a
followup patch, to minimize the churn on this one...)
> pr " PyObject *py_args, *py_ret;\n";
> @@ -3927,6 +3907,12 @@ let print_python_binding name { args; ret } =
&g...
2019 Jul 16
2
[PATCH libnbd v2] generator: Define new Closure type
As before, but this one has working Python bindings. OCaml still TBD.
Rich.
2023 Feb 17
1
[PATCH 1/2] python: Avoid crash if callback parameters cannot be built
...rate, at this point, args is
back to refcount 1.
> > -
> > if (py_r != NULL)
> > Py_DECREF (py_r);
> > else
> > /* Callback threw an exception: print it. */
> > PyErr_PrintEx (0);
> >
> > + out:
> > PyGILState_Release (py_save);
> > }
...and we are STILL not releasing our count, of either py_array, or of args.
If I understand Python bindings in C correctly, you want to
unconditionally decrement the refcount of py_array after Py_BuildValue
(either reducing it to 0 because args is NULL and you don't need py_a...