Ulli Horlacher <frams...@rus.uni-stuttgart.de>: > Hmmm... not so simple for me. My test code: > > from time import * > import threading > import sys > > def hello(): > raise ValueError("hello!!!") > > t = threading.Timer(3.0,hello) > t.start() > try: > print "start" > sleep(5) > print "end" > except ValueError as e: > print e.args[0] > sys.exit(1)
Correct. The timer callback function (hello) would be called in a separate thread. An exception raised in one thread cannot be caught in the main thread. In general, there is no way for a thread to interrupt a sibling thread that is in a blocking function call. Marko -- https://mail.python.org/mailman/listinfo/python-list