[PyQt] sip. setdestroyonexit

Erik Hvatum ice.rikh at gmail.com
Mon Aug 15 21:31:35 BST 2016


You can get into trouble when QObject derivatives are deleted during last-pass garbage collection at interpreter exit.

As you say, in a well designed application, this is generally avoidable.  If you have background QThreads or tricky Python QObject derivative reference loops, gracefully stop and del everything problematic in response to the QApplication.instance().aboutToQuit signal.  Another tier of cleanup is provided by the atexit lib; registered atexit calls are executed after aboutToQuit but before the chaos of interpreter shutdown armageddon, making them useful for cleaning up pure Python stuff used by your Qt code.

Cheers,
Erik

> On Aug 15, 2016, at 15:11, Carl Wolff <carl at wolff-online.nl> wrote:
> 
> Hello,
> 
> I succesfully applied sip. setdestroyonexit on a fairly large pyqt4 application suffering from occasional crashes at exit time.
> 
> My question is twofold:
> - why is destroyonexit not set to False by default;
> - Is it (theoretically) possible to live without using this sip call? E.g. by adhering to guidelines regarding pyqt wrapper/qt ownership and qt/python garbage collection? When I read the API documentation of sip.setdestroyonexit carefully, I get the impression that it is impossible to live without this sip call.
> 
> Best regards,
> Carl
> 
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> https://www.riverbankcomputing.com/mailman/listinfo/pyqt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20160815/5c0297ec/attachment.html>


More information about the PyQt mailing list