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


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

How to terminate the function that runs every n seconds

Started byGanesh Pal <ganesh1pal@gmail.com>
First post2015-01-14 18:37 +0530
Last post2015-01-14 18:37 +0530
Articles 1 — 1 participant

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


Contents

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

#83749 — How to terminate the function that runs every n seconds

FromGanesh Pal <ganesh1pal@gmail.com>
Date2015-01-14 18:37 +0530
SubjectHow to terminate the function that runs every n seconds
Message-ID<mailman.17716.1421240850.18130.python-list@python.org>
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

[toc] | [standalone]


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


csiph-web