Re: callback from C DLL returning an int [SEC=PERSONAL]
"Andrew MacIntyre" <[email protected]> Fri, 15 Jul 2011 05:44:18 +0000
| Newsgroups | gmane.comp.python.ctypes |
|---|---|
| Message-ID | <A1E4E9D08D14924498E135FB4441EE8D07196E58@act01exmbx01vp.internal.govt> |
From: RayS > I had tried making the callback a module or class level function as well, and, I also made the callback function reference a class attribute etc. - nothing helps. > > I just jin'd the following simplest possible code, which shows that the crash is upon the return of the callback: > - if the callback function sleep() is longer than the last sleep() then the second print in the callback is not done, the program exits before the callback is done, and no error > - if the callback sleep is less the function completes, Windoze freaks, and the app finishes execution! If the callback genuinely is a C void function, then I'd have to say that the library that calls it expects it to do something which your code isn't doing - such as copying data out of a buffer and then clearing the buffer - and the library code is subsequently blowing up as a result of what ever needs doing having not been done (or been signalled to have been done). Do you have examples of callbacks in other languages? Another possibility could be the calling convention used for the callback function itself (as distinct from the convention used for the function that sets the callback). You really need the C++ header file for the DLL to evaluate this (I'm assuming C++ based on the snippets posted in your original message). > This also points out that the callback does not block, is it outside the GIL? According to the Python 2.7 docs (section 15.16.2.4), for CFUNCTYPE functions, yes. -------------------------> "These thoughts are mine alone!" <--------- Andrew MacIntyre Operations Branch tel: +61 2 6219 5356 Communications Infrastructure Division fax: +61 2 6253 3277 Australian Communications & Media Authority email: [email protected] http://www.acma.gov.au/ NOTICE: This email message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. ------------------------------------------------------------------------------ AppSumo Presents a FREE Video for the SourceForge Community by Eric Ries, the creator of the Lean Startup Methodology on "Lean Startup Secrets Revealed." This video shows you how to validate your ideas, optimize your ideas and identify your business strategy. http://p.sf.net/sfu/appsumosfdev2dev