[wxpython-users] handling of PyDeadObjectErrors
Jürgen Kareta
python at kareta.de
Tue Apr 8 14:38:16 PDT 2008
Robin Dunn schrieb:
> Jürgen Kareta wrote:
>> Hello,
>>
>> currently working on a somewhat complex project using matplotlib I
>> came across some wx.PyDeadObjectErrors.
>> For example I build my own legend frames (wx.MiniFrame) which are
>> deleted and recreated when ever the user
>> selects to show a new plot.
>>
>> I'm able to fetch the errors in a try/except clause, but I wonder if
>> there is a way to force the python GC to delete the python object
>> immediately after the C++ object is deleted.
>
> No, you wouldn't want to do that even if it was possible. At best it
> would result in unexplained attribute errors for those references
> which used to exist but now don't.
>
Hi Robin,
could you please explain it a bit further. What is the common way to
avoid or handle this dead objects ? I have two scenarios where my code
produce them. First is deleting a line, plot or other component in a
matplotlib figure (and recreating a similar object later) and second
sending a signal with pydispatcher where a deleted object is still in
the observerlist. Pydispatcher usually cares itself about
disconnecting/deleting references to deleted objects.
Fetching those errors with a try/except clause seems to be a bit ugly
and errorphrone. Tried to disconnect the objects from the observerlist
manually before deleting the object but that doesn't work always.
Thanks,
Jürgen
More information about the wxpython-users
mailing list