Re: Crash using callback

Peter Hansen <[email protected]> Thu, 05 Oct 2006 13:17:28 -0400
Newsgroups gmane.comp.python.ctypes.devel
Message-ID <[email protected]>
Victor Stinner wrote:
> Question: would it be possible to change object lifetime, tell that the 
> function keep a referrence of the object, or something like that? Or should I 
> keep a copy of "mycallback = callback_t(mine)" somewhere?

I'm pretty sure you must keep a reference in Python, or it will be (via 
reference counting) freed up immediately.  I'm also (slightly less, but 
still fairly) sure that the documentation on callbacks points something 
like this out... maybe double-check there again?

-Peter

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV