Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3a.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.017 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'executed': 0.09; 'subject:How': 0.10; 'python': 0.11; 'def': 0.12; 'jan': 0.12; '2.7': 0.14; 'prevent': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'bit': 0.19; '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; 'hours': 0.66; 'urgent': 0.67; '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=O35fh7mP2UhwJTb9M+2nRG+fOan3ZgcS1RvQW9KLRec=; b=IfwD44Y+aEKqVNoFurIUIwIJxN7FQ7smMHlwF6chrW9Z3RGuBRlHUkXGQ4lq3fEj9F VMZgAN7UIsm760juNTKhdi6ta5ZtSKl2aqHrySFO6HklSpFaeso67j5X0PJzMbSkmqR7 KNqXZKHEe0nHcC8censpX5Fqu1j8gU5oxchm/ldUyWvgx76hM1Y62CZAJw/gPQ2htYZI xisDKMhw6QxRbxK+Jpt6SkYMR5jNoSM+u6yW7KoCl2EJjPCUVSJwNkKHIYIeu/fboMeP FOmYfh18fKACa4EYM0IBGOJVcIOE2xWaktttfV9IE4YzDQ7bI34QL+N2FnShS4ZFT4Rs mYkA== MIME-Version: 1.0 X-Received: by 10.152.3.195 with SMTP id e3mr4529462lae.8.1421247816584; Wed, 14 Jan 2015 07:03:36 -0800 (PST) In-Reply-To: References: Date: Wed, 14 Jan 2015 20:33:36 +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: 35 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1421247820 news.xs4all.nl 2894 [2001:888:2000:d::a6]:46750 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:83759 This is bit urgent and I all stuck form last few hours :( 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