search for: pyinit_libnbdmod

Displaying 13 results from an estimated 13 matches for "pyinit_libnbdmod".

2019 Jun 28
3
[PATCH libnbd v2] python: Raise a custom exception containing error string and errno.
This kind of fixes the problems in v1. The exception still primarily lives in the libnbdmod and you could still refer to it using libnbdmod.Error (but don't do that). However when the exception is printed it now appears as nbd.Error, and you can catch it also using the same name. Other problems: - There is no "nice" interface to accessing the exception fields. You have to use
2019 Jun 28
0
[PATCH libnbd v2] python: Raise a custom exception containing error string and errno.
...ong (nbd_get_errno ())); + PyErr_SetObject (nbd_internal_py_Error, args); +} + "; List.iter ( @@ -3390,6 +3403,9 @@ static struct PyModuleDef moduledef = { NULL, /* m_free */ }; +/* nbd.Error exception. */ +PyObject *nbd_internal_py_Error; + extern PyMODINIT_FUNC PyInit_libnbdmod (void); PyMODINIT_FUNC @@ -3401,6 +3417,19 @@ PyInit_libnbdmod (void) if (mod == NULL) return NULL; + nbd_internal_py_Error = PyErr_NewExceptionWithDoc ( + \"nbd.Error\", + \"Exception thrown when the underlying libnbd call fails. This\\n\" + \"excep...
2019 Jun 28
1
[PATCH libnbd] python: Raise a custom exception containing error string and errno.
I spent a good few hours this morning trying to make this work and came up with the following patch. It's not quite right though. The exception I've created exists in the libnbdmod module (ie. the underlying C module that we use for the Python bindings). Ideally we'd define and throw an exception from the normal nbd module, but I couldn't work out how to do that. Probably
2019 Jun 28
0
[PATCH libnbd v3] python: Raise a custom exception containing error string and errno.
...ong (nbd_get_errno ())); + PyErr_SetObject (nbd_internal_py_Error, args); +} + "; List.iter ( @@ -3390,6 +3403,9 @@ static struct PyModuleDef moduledef = { NULL, /* m_free */ }; +/* nbd.Error exception. */ +PyObject *nbd_internal_py_Error; + extern PyMODINIT_FUNC PyInit_libnbdmod (void); PyMODINIT_FUNC @@ -3401,6 +3417,11 @@ PyInit_libnbdmod (void) if (mod == NULL) return NULL; + nbd_internal_py_Error = PyErr_NewException (\"nbd.Error\", NULL, NULL); + if (nbd_internal_py_Error == NULL) + return NULL; + PyModule_AddObject (mod, \"Error\&quo...
2019 Jun 28
3
[PATCH libnbd v3] python: Raise a custom exception containing error string and errno.
Following Eric's suggestions from v2, this adds .string, .errno and .__str__ properties. The .string property returns the error string. The .errno property returns the errno (from the errno module), or None. The __str__ property makes the exception nicely printable. Rich.
2019 Aug 13
0
[PATCH libnbd 2/6] generator: Create only one Python wrapper per closure.
...hods.c --- generator/generator | 237 ++++++++++++++++++++++---------------------- 1 file changed, 117 insertions(+), 120 deletions(-) diff --git a/generator/generator b/generator/generator index 9dbef2a..a031bd0 100755 --- a/generator/generator +++ b/generator/generator @@ -4108,126 +4108,122 @@ PyInit_libnbdmod (void) } " +(* Functions with a Closure parameter are special because we + * have to generate wrapper functions which translate the + * callbacks back to Python. + *) +let print_python_closure_wrapper { cbname; cbargs } = + pr "/* Wrapper for %s callback. */\n" cbname; + pr &qu...
2019 Jul 25
2
[libnbd PATCH] generator: Let nbd_aio_get_direction return unsigned
...errcode with + | Some value -> value + | None -> assert false in + pr "On error C<%s> is returned.\n" value; pr "See L<libnbd(3)/ERROR HANDLING> for how to get further details\n"; pr "of the error.\n" ) @@ -3683,7 +3698,7 @@ PyInit_libnbdmod (void) } " -let print_python_binding name { args; ret } = +let print_python_binding name { args; ret; may_set_error } = (* Functions with a Closure parameter are special because we * have to generate wrapper functions which translate the * callbacks back to Python. @@ -3835,6 +38...
2019 Aug 09
0
[PATCH libnbd 2/2] generator: Change handling of Flags to be a true optional argument.
...d2 %s —\n" name; pr "%s\n" shortdesc; pr "\n"; pr " "; - print_call name args ret; pr ";"; + print_call name args optargs ret; pr ";"; pr "\n"; pr "\n"; pr "%s\n" longdesc; @@ -4020,7 +4042,7 @@ PyInit_libnbdmod (void) } " -let print_python_binding name { args; ret; may_set_error } = +let print_python_binding name { args; optargs; ret; may_set_error } = (* Functions with a Closure parameter are special because we * have to generate wrapper functions which translate the * callbacks back...
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.
...(void *data); + typedef void (*nbd_close_callback) (void *user_data); int nbd_add_close_callback (struct nbd_handle *nbd, - nbd_close_callback cb, void *data); + nbd_close_callback cb, void *user_data); "; @@ -3709,159 +3726,160 @@ PyInit_libnbdmod (void) " let print_python_binding name { args; ret } = - (* Functions with a callback parameter are special because we - * have to generate a wrapper function which translates the - * callback parameters back to Python. + (* Functions with a Closure parameter are special because we +...
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.
2019 Aug 09
4
[PATCH libnbd 0/2] generator: Preparatory changes to the generator.
These are some simplifications to the generator. They don't probably make much sense on their own, but they are preparatory to better handling of enums, and or'd lists of flags. Rich.
2019 May 23
2
[PATCH libnbd] api: Get rid of nbd_connection.
This isn't quite finished because not all of the tests or examples have been updated, but it demonstrates an idea: Should we forget about the concept of having multiple connections managed under a single handle? In this patch there is a single ‘struct nbd_handle *’ which manages a single state machine and connection (and therefore no nbd_connection). To connect to a multi-conn server you must