adding a simulation mode

andrea crotti andrea.crotti.0 at
Wed Jul 4 16:19:15 CEST 2012

> Yes there is no easy solution apparently..  But I'm also playing
> around with vagrant and virtual machine generations, suppose I'm able
> to really control what will be on the machine at time X, creating it
> on demand with what I need, it might be a good way to solve my
> problems (a bit overkill and slow maybe though).
> I'll try the sys.excepthook trick first, any error should give me an
> exception, so if I catch them all I think it might work already..

I actually thought that the sys.excepthook would be easy but it's not
so trivial apparently:
This simple sample never reaches the print("here"), because even if
the exception is catched it still quits with return code=1.

I also tried to catch the signal but same result, how do I make it
continue and just don't complain?

The other option if of course to do a big try/except, but I would
prefer the excepthook solution..

import sys
from shutil import copy

def my_except_hook(etype, value, tb):
    print("got an exception of type", etype)

if __name__ == '__main__':
    sys.excepthook = my_except_hook

More information about the Python-list mailing list