Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Marko Rauhamaa Newsgroups: comp.lang.python Subject: Re: cross platform alternative for signal.SIGALRM? Date: Wed, 11 Nov 2015 20:03:12 +0200 Organization: A noiseless patient Spider Lines: 28 Message-ID: <87oaf0tnvj.fsf@elektro.pacujo.net> References: <87si4cts68.fsf@elektro.pacujo.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="b7cb1518d23ec19d482dcc9c31d30fdd"; logging-data="20998"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19G+qHtN7gF9IsW0B0w3CHF" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:HXai+WfEZDz6Uxt3ahFE5bv050c= sha1:ZakpXgmVcXC0ChKU1lzz2xC+XPo= Xref: csiph.com comp.lang.python:98657 Ulli Horlacher : > 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