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


Groups > comp.lang.python > #83759

Re: How to terminate the function that runs every n seconds

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 <ganesh1pal@gmail.com>
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 <CACT3xuWvN=zUs5CmuxceG9yv2gPWkmxF2dTgWOr8WqmaJxag+A@mail.gmail.com>
References <CACT3xuWvN=zUs5CmuxceG9yv2gPWkmxF2dTgWOr8WqmaJxag+A@mail.gmail.com>
Date Wed, 14 Jan 2015 20:33:36 +0530
Subject Re: How to terminate the function that runs every n seconds
From Ganesh Pal <ganesh1pal@gmail.com>
To "python-list@python.org" <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 <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>
Newsgroups comp.lang.python
Message-ID <mailman.17723.1421247820.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


This is bit urgent and I all stuck form last few hours   :(

On Wed, Jan 14, 2015 at 6:37 PM, Ganesh Pal <ganesh1pal@gmail.com> 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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: How to terminate the function that runs every n seconds Ganesh Pal <ganesh1pal@gmail.com> - 2015-01-14 20:33 +0530

csiph-web