[PyKDE] problem with exceptions within events

Truls A. Tangstad kerfue+pykde at herocamp.org
Wed Feb 23 20:10:30 GMT 2005


On Wed, Feb 23, 2005 at 06:55:38PM +0100, Giovanni Bajo wrote:
> Hello,
> 
> it seems that Python exceptions generated within event handlers do not get
> propagated correctly. We use a sys.excepthook to abort gracefully with a
> messagebox from our application, and this seems to work in most cases but
> not within event handlers.

I think this is by design as most event-triggers are not prepared to
handle an exception caused by an event.

I had the same problem, but after thinking about it for a while i
realized that having events propagate exceptions to the initiator
would at most times be problematic and probably cause more problems
then what would be gained by what you are trying to achieve.

Events are often sent from other threads and end up in a thread-queue
in the main thread (event/gui-thread). The gui loops through this
thread and sends events where needed. If the handler of an event
throws an exception, there's now nowhere for it to go, except causing
the event-loop to crash... which Qt (PyQt?) solves by instead printing
the exception and then ditching it.

I'm sure someone will correct me if I'm off the mark here...

-- 
Truls A. Tangstad - <kerfue+pykde at h e r o c a m p.org>




More information about the PyQt mailing list