I am working on a project where a function is throwing a wx.pyDeadObject Error
because of a delayed task.
I've read that in wx you can check if the c++ object still exsists by running if self:
, however this no longer works in wxPython 3.0.2. using wx 3.
I've modified the function to the following:
def SetData(self, delayedResult):
if not self or not self.list:
return
data = []
torrents = delayedResult.get()
for torrent in torrents:
data.append((torrent.infohash, [torrent.name], torrent, ThumbnailListItemNoTorrent))
self_exist = True
list_exists = True
if not self:
self_exist = False
if not self.list:
list_exists = False
try:
self.list.SetData(data)
self.list.SetupScrolling()
except wx.PyDeadObjectError:
print "Self existed: %s and self.list existed: %s" % (self_exist, list_exists)
It already passes the first if statement, but since the delayedResutlt.get()
is blocking I added the additional try except (I also tried duplicating that if statement at the start of the function, but that didn't work).
When running one of the unit tests I got Self existed: True and self.list existed: True
which confirmed my suspicions. The documentation of 3.0.3 says this should be present.
How can you test if the c++ part of a wx object has been deleted in wxPython?