[pygtk] exception handling
John Hunter
jdh2358 at gmail.com
Fri Jan 30 03:00:20 WST 2009
If I raise an exception in a gobject timeout function, is there a way
for me to catch it hand handle it in the main thread? Here I
try/except the "run" method, but the exception does not propagate. I
recall there are difficulties in cross thread signal and exception
handling, and am wondering what the right approach is. I am not
writing a UI here, just using the gobject event loop in a cron script.
Here is some example code
import gobject
def ontimer(*args):
print 'ontimer'
raise RuntimeError('Ouch')
return True
gobject.timeout_add(1000, ontimer)
loop = gobject.MainLoop()
try: loop.run()
except RuntimeError:
loop.quit()
print 'all done'
Using pygtk 2.10
Thanks,
JDH
More information about the pygtk
mailing list