Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.036 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'assignment': 0.07; 'matches': 0.07; 'subject:How': 0.10; 'cc:addr:python-list': 0.11; 'thread': 0.14; 'assignment?': 0.16; 'subroutine': 0.16; 'threads,': 0.16; 'fix': 0.17; 'variable': 0.18; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'first,': 0.26; 'posts': 0.26; 'header:In-Reply-To:1': 0.27; 'message- id:@mail.gmail.com': 0.30; 'subject:that': 0.31; 'terminate': 0.31; 'figure': 0.32; 'run': 0.32; 'subject:the': 0.34; 'something': 0.35; 'test': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; "didn't": 0.36; 'thanks': 0.36; 'wrong': 0.37; 'itself': 0.39; 'sure': 0.39; 'how': 0.40; 'new': 0.61; 'back': 0.62; 'complete': 0.62; 'making': 0.63; 'school': 0.64; 'finish': 0.65; 'reply': 0.66; 'minutes': 0.67 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 :cc:content-type; bh=aWiC9D6K8NjKWfqA21DG+Lanmw4EZB0oTEYIKUDwIww=; b=wy1iyp6zpxvMzRojtH3dx8TOmzrvTXaxg+NNk/rx1gRLXxYfW7k+a5yrrGDvW8Ye28 psu+8bk+ol68Mac9vdGoR9hY2qqqOOW8l0Q+wsyb0xoLvJsL8lLVLtgAHcJ+PwJXFd+r Bjp03rrNXYw4dr4/xGmuXYnCyP44raOr8ZgX+dLvZ6c+usxFlLoikRNU4VMDHS4KuzQo LoPXuFEedp60EaqiNjr/ABM7+0n7ko2kxBpGQvB6dNkTlKbxxhQHAjLNHxQTHDJjN2hs 0Pel0lcD7vPSDI+KqbYlI/YkcLURKuIDb/qJ7fnmfc3+4XUNEu3Ipn6X/eZTnMhkEdiM e9bg== MIME-Version: 1.0 X-Received: by 10.112.119.167 with SMTP id kv7mr5296334lbb.62.1421256371919; Wed, 14 Jan 2015 09:26:11 -0800 (PST) In-Reply-To: <54B69A5B.5000801@davea.name> References: <54B69A5B.5000801@davea.name> Date: Wed, 14 Jan 2015 22:56:11 +0530 Subject: Re: How to terminate the function that runs every n seconds From: Ganesh Pal To: Dave Angel Content-Type: text/plain; charset=UTF-8 Cc: "python-list@python.org" 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: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1421256380 news.xs4all.nl 2934 [2001:888:2000:d::a6]:44592 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:83770 > Do you want to fix the symptom, fix the problem, or finish a school > assignment? To do the first, make a global variable that contains the time > you want to stop making new threads, and conditionally test it before > calling threading.Timer > I firstly apologise for multiple posts and thanks for the reply . I was actually in hurry to complete my assignment and there was no way to figure out what was going wrong !! My assignment was to write a subroutine that run itself every n minutes and terminate before the main thread completes. I thought threading.Timer helped me achieve this but timer.cancel() didn't help me terminate the timer . > Something like > quit_time = timer.time() + 4 > Thanks for the above hint, I will try this and get back to you > Note that neither Timer nor sleep makes any promises about how accurately it > matches the requested time. Sure will keep this in mind Regards , Ganesh