Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #98661
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: cross platform alternative for signal.SIGALRM? |
| Date | 2015-11-11 19:42 -0500 |
| Organization | IISS Elusive Unicorn |
| Message-ID | <mailman.250.1447289010.16136.python-list@python.org> (permalink) |
| References | <n1vpl3$hrl$1@news2.informatik.uni-stuttgart.de> <87si4cts68.fsf@elektro.pacujo.net> <n1vsj6$ijf$1@news2.informatik.uni-stuttgart.de> |
On Wed, 11 Nov 2015 17:06:46 +0000 (UTC), Ulli Horlacher
<framstag@rus.uni-stuttgart.de> declaimed the following:
>Marko Rauhamaa <marko@pacujo.net> wrote:
>> Ulli Horlacher <framstag@rus.uni-stuttgart.de>:
>>
>> > What is the best practise for a cross platform timeout handler?
>>
>> Here's the simplest answer:
>>
>> https://docs.python.org/3/library/threading.html#threading.Timer
>>
>> (Also available in Python 2.)
>
>Hmmm... not so simple for me. My test code:
>
>from time import *
>import threading
>import sys
>
>def hello():
>raise ValueError("hello!!!")
>
Indentation!
If that is a cut&paste, you have defined a "hello" function that does
nothing, followed by immediately raising ValueError (so nothing below will
be executed)
>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)
>
>
>gives:
>
>
>start
>Exception in thread Thread-1:
>Traceback (most recent call last):
> File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner
> self.run()
> File "/usr/lib/python2.7/threading.py", line 759, in run
> self.function(*self.args, **self.kwargs)
> File "x.py", line 7, in hello
> def hello(): raise ValueError("hello!!!")
>ValueError: hello!!!
>
But this indicates the thread stuff did run, so your copying into the
post is incorrect.
{Please take my post, then, as an advisory to take care when posting Python
code that the indentation is correct in the posted version -- not taking
such care has caused many wild-goose chases for other posters}
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
cross platform alternative for signal.SIGALRM? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-11-11 16:16 +0000
Re: cross platform alternative for signal.SIGALRM? Marko Rauhamaa <marko@pacujo.net> - 2015-11-11 18:30 +0200
Re: cross platform alternative for signal.SIGALRM? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-11-11 17:06 +0000
Re: cross platform alternative for signal.SIGALRM? Marko Rauhamaa <marko@pacujo.net> - 2015-11-11 20:03 +0200
Re: cross platform alternative for signal.SIGALRM? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-11-11 22:42 +0000
Re: cross platform alternative for signal.SIGALRM? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-11-11 19:42 -0500
Re: cross platform alternative for signal.SIGALRM? Terry Reedy <tjreedy@udel.edu> - 2015-11-11 20:37 -0500
Re: cross platform alternative for signal.SIGALRM? Marko Rauhamaa <marko@pacujo.net> - 2015-11-12 08:14 +0200
Re: cross platform alternative for signal.SIGALRM? Christian Gollwitzer <auriocus@gmx.de> - 2015-11-12 07:43 +0100
Re: cross platform alternative for signal.SIGALRM? Chris Angelico <rosuav@gmail.com> - 2015-11-12 18:37 +1100
Re: cross platform alternative for signal.SIGALRM? Terry Reedy <tjreedy@udel.edu> - 2015-11-12 05:15 -0500
Re: cross platform alternative for signal.SIGALRM? Chris Angelico <rosuav@gmail.com> - 2015-11-12 22:38 +1100
Re: cross platform alternative for signal.SIGALRM? Terry Reedy <tjreedy@udel.edu> - 2015-11-12 09:01 -0500
Re: cross platform alternative for signal.SIGALRM? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-11-12 07:22 +0000
Re: cross platform alternative for signal.SIGALRM? Marko Rauhamaa <marko@pacujo.net> - 2015-11-12 10:15 +0200
Re: cross platform alternative for signal.SIGALRM? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-11-12 06:58 +0000
Re: cross platform alternative for signal.SIGALRM? Cameron Simpson <cs@zip.com.au> - 2015-11-12 16:20 +1100
csiph-web