Writing a callback function in Python to be consumed by a C routine in a loaded API. Callback function has va_listWriting Python ctypes for Function pointer callback function in Cmkdir -p functionality in PythonWhat is a callback function?Wrapping a C library in Python: C, Cython or ctypes?Why do people write the #!/usr/bin/env python shebang on the first line of a Python script?How to return value from an asynchronous callback function?How to get contents of va_list in Python?Why does Python code run faster in a function?Can I create a prototype for a variadic Python function using ctypes so that a DLL can call this function as a callback?How do I convert an existing callback API to promises?Python Ctypes register callback functions
Gory anime with pink haired girl escaping an asylum
Why do airports remove/realign runways?
Groups where no elements commute except for the trivial cases
Why do Martians have to wear space helmets?
How to find the version of extensions used on a Joomla website without access to the backend?
How do amateur satellites stay consistently in the amateur-sat bands acoss the globe?
How would a sea turtle end up on its back?
What is this airplane with small wings at different angles seen at Paphos Airport?
Bringing coumarin-containing liquor into the USA
Why do Klingons use cloaking devices?
Is it acceptable that I plot a time-series figure with years increasing from right to left?
Do I need transit visa for Dublin?
Shipped package arrived - didn't order, possible scam?
How did Einstein know the speed of light was constant?
Minor differences between two recorded guitars
How to get the speed of my spaceship?
Why does this function pointer assignment work when assigned directly but not with the conditional operator?
Array or vector? Two dimensional array or matrix?
How to play a D major chord lower than the open E major chord on guitar?
Howto display unicode character u2026 in terminal mode in emacs
When moving a unique_ptr into a lambda, why is it not possible to call reset?
Do Goblin tokens count as Goblins?
Taking my Ph.D. advisor out for dinner after graduation
Any way to meet code with 40.7% or 40.44% conduit fill?
Writing a callback function in Python to be consumed by a C routine in a loaded API. Callback function has va_list
Writing Python ctypes for Function pointer callback function in Cmkdir -p functionality in PythonWhat is a callback function?Wrapping a C library in Python: C, Cython or ctypes?Why do people write the #!/usr/bin/env python shebang on the first line of a Python script?How to return value from an asynchronous callback function?How to get contents of va_list in Python?Why does Python code run faster in a function?Can I create a prototype for a variadic Python function using ctypes so that a DLL can call this function as a callback?How do I convert an existing callback API to promises?Python Ctypes register callback functions
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
There seems to be some ideas in writing Python callback functions to be consumed by a load C api: Writing Python ctypes for Function pointer callback function in C
Thanks! This is useful.
I have some callback functions that are of the form:
LogCallback(enum messtype, OurNode *node, OurLink *link, OurContract *contract, char *format, va_list argptr)
I am mainly interested in how a python routine can be made to have a va_list such that it can be sent to an API call as a callback function.
Clarification: The callback function format calls for a va_list, so a Python function built to act as a callback function would need to function in the C routines that take in and run this function (pointer).
python c callback
|
show 1 more comment
There seems to be some ideas in writing Python callback functions to be consumed by a load C api: Writing Python ctypes for Function pointer callback function in C
Thanks! This is useful.
I have some callback functions that are of the form:
LogCallback(enum messtype, OurNode *node, OurLink *link, OurContract *contract, char *format, va_list argptr)
I am mainly interested in how a python routine can be made to have a va_list such that it can be sent to an API call as a callback function.
Clarification: The callback function format calls for a va_list, so a Python function built to act as a callback function would need to function in the C routines that take in and run this function (pointer).
python c callback
2
I would expect you need to find a way to bindLogCallback_wrapper(enum messtype, OurNode *, OurLink *, OurContract *, char *, ...)
, which can then construct theva_list
correctly and invokeLogCallback
.
– paddy
Mar 25 at 21:09
I think paddy's got it, I don't think you'll find any sensible way of constructingva_list
in ctypes.
– Antti Haapala
Mar 25 at 21:17
or do you mean that you need to code a Python function that takes inva_list
and processes it? That's 99 % impossibility... or at least 100 % masochism :D
– Antti Haapala
Mar 25 at 21:18
Actually re-reading the question... it is unclear what do you need, perhaps some code would clarify.
– Antti Haapala
Mar 25 at 21:31
Nothing would stop you from writing a C function to convertformat
andargptr
into, say, atuple
which could be passed to whatever Python function. Doing it entirely viactypes
is likely to be painful.
– Davis Herring
Mar 25 at 22:51
|
show 1 more comment
There seems to be some ideas in writing Python callback functions to be consumed by a load C api: Writing Python ctypes for Function pointer callback function in C
Thanks! This is useful.
I have some callback functions that are of the form:
LogCallback(enum messtype, OurNode *node, OurLink *link, OurContract *contract, char *format, va_list argptr)
I am mainly interested in how a python routine can be made to have a va_list such that it can be sent to an API call as a callback function.
Clarification: The callback function format calls for a va_list, so a Python function built to act as a callback function would need to function in the C routines that take in and run this function (pointer).
python c callback
There seems to be some ideas in writing Python callback functions to be consumed by a load C api: Writing Python ctypes for Function pointer callback function in C
Thanks! This is useful.
I have some callback functions that are of the form:
LogCallback(enum messtype, OurNode *node, OurLink *link, OurContract *contract, char *format, va_list argptr)
I am mainly interested in how a python routine can be made to have a va_list such that it can be sent to an API call as a callback function.
Clarification: The callback function format calls for a va_list, so a Python function built to act as a callback function would need to function in the C routines that take in and run this function (pointer).
python c callback
python c callback
edited Mar 26 at 13:09
Jiminion
asked Mar 25 at 20:40
JiminionJiminion
3,8411 gold badge17 silver badges40 bronze badges
3,8411 gold badge17 silver badges40 bronze badges
2
I would expect you need to find a way to bindLogCallback_wrapper(enum messtype, OurNode *, OurLink *, OurContract *, char *, ...)
, which can then construct theva_list
correctly and invokeLogCallback
.
– paddy
Mar 25 at 21:09
I think paddy's got it, I don't think you'll find any sensible way of constructingva_list
in ctypes.
– Antti Haapala
Mar 25 at 21:17
or do you mean that you need to code a Python function that takes inva_list
and processes it? That's 99 % impossibility... or at least 100 % masochism :D
– Antti Haapala
Mar 25 at 21:18
Actually re-reading the question... it is unclear what do you need, perhaps some code would clarify.
– Antti Haapala
Mar 25 at 21:31
Nothing would stop you from writing a C function to convertformat
andargptr
into, say, atuple
which could be passed to whatever Python function. Doing it entirely viactypes
is likely to be painful.
– Davis Herring
Mar 25 at 22:51
|
show 1 more comment
2
I would expect you need to find a way to bindLogCallback_wrapper(enum messtype, OurNode *, OurLink *, OurContract *, char *, ...)
, which can then construct theva_list
correctly and invokeLogCallback
.
– paddy
Mar 25 at 21:09
I think paddy's got it, I don't think you'll find any sensible way of constructingva_list
in ctypes.
– Antti Haapala
Mar 25 at 21:17
or do you mean that you need to code a Python function that takes inva_list
and processes it? That's 99 % impossibility... or at least 100 % masochism :D
– Antti Haapala
Mar 25 at 21:18
Actually re-reading the question... it is unclear what do you need, perhaps some code would clarify.
– Antti Haapala
Mar 25 at 21:31
Nothing would stop you from writing a C function to convertformat
andargptr
into, say, atuple
which could be passed to whatever Python function. Doing it entirely viactypes
is likely to be painful.
– Davis Herring
Mar 25 at 22:51
2
2
I would expect you need to find a way to bind
LogCallback_wrapper(enum messtype, OurNode *, OurLink *, OurContract *, char *, ...)
, which can then construct the va_list
correctly and invoke LogCallback
.– paddy
Mar 25 at 21:09
I would expect you need to find a way to bind
LogCallback_wrapper(enum messtype, OurNode *, OurLink *, OurContract *, char *, ...)
, which can then construct the va_list
correctly and invoke LogCallback
.– paddy
Mar 25 at 21:09
I think paddy's got it, I don't think you'll find any sensible way of constructing
va_list
in ctypes.– Antti Haapala
Mar 25 at 21:17
I think paddy's got it, I don't think you'll find any sensible way of constructing
va_list
in ctypes.– Antti Haapala
Mar 25 at 21:17
or do you mean that you need to code a Python function that takes in
va_list
and processes it? That's 99 % impossibility... or at least 100 % masochism :D– Antti Haapala
Mar 25 at 21:18
or do you mean that you need to code a Python function that takes in
va_list
and processes it? That's 99 % impossibility... or at least 100 % masochism :D– Antti Haapala
Mar 25 at 21:18
Actually re-reading the question... it is unclear what do you need, perhaps some code would clarify.
– Antti Haapala
Mar 25 at 21:31
Actually re-reading the question... it is unclear what do you need, perhaps some code would clarify.
– Antti Haapala
Mar 25 at 21:31
Nothing would stop you from writing a C function to convert
format
and argptr
into, say, a tuple
which could be passed to whatever Python function. Doing it entirely via ctypes
is likely to be painful.– Davis Herring
Mar 25 at 22:51
Nothing would stop you from writing a C function to convert
format
and argptr
into, say, a tuple
which could be passed to whatever Python function. Doing it entirely via ctypes
is likely to be painful.– Davis Herring
Mar 25 at 22:51
|
show 1 more comment
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55346091%2fwriting-a-callback-function-in-python-to-be-consumed-by-a-c-routine-in-a-loaded%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55346091%2fwriting-a-callback-function-in-python-to-be-consumed-by-a-c-routine-in-a-loaded%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
I would expect you need to find a way to bind
LogCallback_wrapper(enum messtype, OurNode *, OurLink *, OurContract *, char *, ...)
, which can then construct theva_list
correctly and invokeLogCallback
.– paddy
Mar 25 at 21:09
I think paddy's got it, I don't think you'll find any sensible way of constructing
va_list
in ctypes.– Antti Haapala
Mar 25 at 21:17
or do you mean that you need to code a Python function that takes in
va_list
and processes it? That's 99 % impossibility... or at least 100 % masochism :D– Antti Haapala
Mar 25 at 21:18
Actually re-reading the question... it is unclear what do you need, perhaps some code would clarify.
– Antti Haapala
Mar 25 at 21:31
Nothing would stop you from writing a C function to convert
format
andargptr
into, say, atuple
which could be passed to whatever Python function. Doing it entirely viactypes
is likely to be painful.– Davis Herring
Mar 25 at 22:51