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


Groups > comp.lang.python > #8636 > unrolled thread

Re: how to call a function for evry 10 secs

Started byRune Strand <rune.strand@gmail.com>
First post2011-07-01 09:15 -0700
Last post2011-07-01 09:57 -0700
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  Re: how to call a function for evry 10 secs Rune Strand <rune.strand@gmail.com> - 2011-07-01 09:15 -0700
    Re: how to call a function for evry 10 secs Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2011-07-01 09:57 -0700

#8636 — Re: how to call a function for evry 10 secs

FromRune Strand <rune.strand@gmail.com>
Date2011-07-01 09:15 -0700
SubjectRe: how to call a function for evry 10 secs
Message-ID<0dced078-212a-4841-9e1c-704697c4bcc6@glegroupsg2000goo.googlegroups.com>
from threading import Timer

def Func_to_call:
   do_stuff()

my_timer = Timer(10, Func_to_call)
my_timer.start()

[toc] | [next] | [standalone]


#8638

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2011-07-01 09:57 -0700
Message-ID<mailman.543.1309539450.1164.python-list@python.org>
In reply to#8636
On Fri, 1 Jul 2011 09:15:19 -0700 (PDT), Rune Strand
<rune.strand@gmail.com> declaimed the following in
gmane.comp.python.general:

> from threading import Timer
> 
> def Func_to_call:
>    do_stuff()
> 
> my_timer = Timer(10, Func_to_call)
> my_timer.start()

	Timer() is a one-shot; per the OPs requirements even it would need
to be placed within a loop to invoke multiple calls -- so there isn't
much gain in terms of lines of code... And worse, since it calls the
function asynchronously and not sequentially, a delay time for each
instance would have to be computed inside the loop too...
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
        wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web