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: Thu, 12 Nov 2015 10:15:48 +0200 Organization: A noiseless patient Spider Lines: 22 Message-ID: <87vb97skej.fsf@elektro.pacujo.net> References: <877flnu4kn.fsf@elektro.pacujo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: mx02.eternal-september.org; posting-host="b7cb1518d23ec19d482dcc9c31d30fdd"; logging-data="25803"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19gAwUsSsYmqp1wq9L6Thma" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:Ar5XJ7CNoLRwGU7t9N+VybHxJGg= sha1:xWZ3M/6tX7SGDTqeTgr0/LKUDJ8= Xref: csiph.com comp.lang.python:98679 Ulli Horlacher : > Marko Rauhamaa wrote: > >> I'm thinking the only portable way is to run a watchdog process with >> subprocess or multiprocessing. > > How can a subprocess interrupt a function in another process? > > For example: waiting for user input with a timeout. > > raw_input("Hit ENTER to continue or wait 10 s") By sending the parent a signal with os.kill(). Now, signal handling in Python is brittle so you must be careful: There is no way to “block” signals temporarily from critical sections Marko