Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'executed': 0.09; 'subject:How': 0.10; 'python': 0.11; 'def': 0.12; 'jan': 0.12; '2.7': 0.14; 'typos': 0.16; 'prevent': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'import': 0.22; 'to:name:python-list@python.org': 0.22; 'print': 0.22; '(a)': 0.24; 'question': 0.24; 'header:In- Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'subject:that': 0.31; 'linux': 0.33; 'running': 0.33; 'subject:the': 0.34; 'received:google.com': 0.35; '14,': 0.36; 'module.': 0.36; 'seconds': 0.37; 'same.': 0.38; 'to:addr:python- list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; '2015': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=HT2rKjlpM2oZmrMJQo1fkBz53XP6gdrlodj425LadVI=; b=cPA3yuVKzsZggKTgB4qD/Koe11QcMHDJ19NUYBIfF4FmezBLgBPTgt8Dhk0yi0yEmK aewQYjojJCAuIj470BJbQeJwsgdj26LrxGrJfhf03j1CLc/UZG07055/HCnqiBzKrego Eh1z5RCvoIv3aXDp/zrLuxCSjnXDukspjQkKNObnaVEA0rvzM3mQMVkJ09Qa5rX7hUxY IfMZC5wbiJnOyUflsd7OWHk3NrT9JUsJkPUZCNQi7BnXXDGFpHw3YusunLDvCELHGb/3 k+ywmZjEa110NBp1w8mn1srnFTs2mlotlL5jpsNv2SyQfwrDFSGwXhnCi8eUp4XqKkjY afUw== MIME-Version: 1.0 X-Received: by 10.152.206.41 with SMTP id ll9mr3944223lac.62.1421240985475; Wed, 14 Jan 2015 05:09:45 -0800 (PST) In-Reply-To: References: Date: Wed, 14 Jan 2015 18:39:45 +0530 Subject: Re: How to terminate the function that runs every n seconds From: Ganesh Pal To: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 39 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1421240993 news.xs4all.nl 2955 [2001:888:2000:d::a6]:45060 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:83750 Corrected Typos . >a) How to I prevent the execution of Print "EXECUTED SLEEP" after 4 > seconds ? , current this is running in an infinite loop On Wed, Jan 14, 2015 at 6:37 PM, Ganesh Pal wrote: > Iam using Linux and Python 2.7 and playing with the threading.Timer module. > > I had the below question on the same. > > (a) How to I prevent the execution the "EXECUTED SLEEP" after 4 > seconds ? , current this is running in an infinite loop > > node-1# cat file_01.py > > import threading > import time > def printit(): > threading.Timer(2, printit).start() > print "EXECUTED SLEEP" > printit() > print "hi" > time.sleep(4) > print "hi" > time.sleep(5) > > Output: > node-1# python file_01.py > EXECUTED SLEEP > hi > EXECUTED SLEEP > EXECUTED SLEEP > EXECUTED SLEEP > > > > Regards, > Ganesh