enthought / pyface

pyface: traits-capable windowing framework
Other
105 stars 55 forks source link

BUG: Safe hasattr for PyQt5 #1161

Closed larsoner closed 1 year ago

larsoner commented 1 year ago

Over in https://github.com/enthought/mayavi/pull/1180 I am working on VTK 9.2.2 fixes, and I am getting a segfault in CIs during GC:

https://github.com/enthought/mayavi/actions/runs/3222141217/jobs/5270891488

Locally I don't get a segfault but rather a slightly nicer error message:

Exceptions caught in Qt event loop:
________________________________________________________________________________
Traceback (most recent call last):
  File "/home/larsoner/python/pyface/pyface/ui/qt4/action/action_item.py", line 379, in _qt4_on_destroyed
    if hasattr(self.control, "_tool_instance"):
RuntimeError: wrapped C/C++ object of type QAction has been deleted

This PR fixes this by catching this RuntimeError during hasattr. Locally at least the Mayavi tests pass with PyQt5 with this change.

corranwebster commented 1 year ago

Thanks - this looks like a reasonable fix.

larsoner commented 1 year ago

There was a timeout on one run after 360 minutes (!) that's hopefully unrelated, so rather than pushing an empty commit (to get CIs to run again) I added a timeout-minutes: 20 to the CI run. Looks like all others were < 5 minutes so this seemed like a reasonable buffer against slow downloads and such.

corranwebster commented 1 year ago

Yes, it is almost certainly orthogonal - I haven't seen that sort of error in the CI runs, but I will keep an eye out for it in the future.

I think this should be good to merge.