Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #98661

Re: cross platform alternative for signal.SIGALRM?

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Newsgroups comp.lang.python
Subject Re: cross platform alternative for signal.SIGALRM?
Date Wed, 11 Nov 2015 19:42:57 -0500
Organization IISS Elusive Unicorn
Lines 65
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>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Trace news.uni-berlin.de FL0X6haU/v6GPI3X6Clogg4K99eu6tk0ZntDOvDq/Bvg==
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:skip:s 10': 0.05; 'sys': 0.05; '(so': 0.07; 'run,': 0.07; 'e.args[0]': 0.09; 'indicates': 0.09; 'message-id:@4ax.com': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'timeout': 0.09; 'valueerror': 0.09; 'thread': 0.10; 'python': 0.10; 'def': 0.13; 'wed,': 0.15; '"end"': 0.16; '(also': 0.16; '2.)': 0.16; '>try:': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'subject:alternative': 0.16; 'sys.exit(1)': 0.16; 'threading': 0.16; 'wrote:': 0.16; 'url:home': 0.18; '2015': 0.20; 'skip:" 30': 0.20; 'posted': 0.21; 'defined': 0.23; 'import': 0.24; '(most': 0.24; 'header:X-Complaints-To:1': 0.26; '+0000': 0.27; 'followed': 0.27; 'correct': 0.28; 'function': 0.28; 'indentation': 0.29; 'code:': 0.29; 'raise': 0.29; 'print': 0.30; 'code': 0.30; 'post': 0.31; 'skip:_ 10': 0.32; 'posting': 0.32; 'run': 0.33; 'url:python': 0.33; 'raising': 0.33; 'file': 0.34; 'nov': 0.35; 'but': 0.36; 'url:org': 0.36; 'url:library': 0.36; 'to:addr :python-list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'charset:us-ascii': 0.37; 'skip:v 20': 0.38; 'version': 0.38; 'stuff': 0.38; 'copying': 0.38; 'test': 0.39; 'does': 0.39; 'to:addr:python.org': 0.40; 'url:3': 0.60; 'care': 0.60; 'your': 0.60; 'caused': 0.61; '>from': 0.76; '(utc),': 0.84; '>def': 0.84; 'advisory': 0.84; 'answer:': 0.84; 'post,': 0.84; 'self.run()': 0.84; 'dennis': 0.91
X-Injected-Via-Gmane http://gmane.org/
X-Gmane-NNTP-Posting-Host adsl-108-68-178-61.dsl.klmzmi.sbcglobal.net
X-Newsreader Forte Agent 6.00/32.1186
X-No-Archive YES
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:98661

Show key headers only | View raw


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 | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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