Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #83797 > unrolled thread
| Started by | "Frank Millman" <frank@chagford.com> |
|---|---|
| First post | 2015-01-15 08:56 +0200 |
| Last post | 2015-01-15 08:56 +0200 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: How to terminate the function that runs every n seconds "Frank Millman" <frank@chagford.com> - 2015-01-15 08:56 +0200
| From | "Frank Millman" <frank@chagford.com> |
|---|---|
| Date | 2015-01-15 08:56 +0200 |
| Subject | Re: How to terminate the function that runs every n seconds |
| Message-ID | <mailman.17742.1421304984.18130.python-list@python.org> |
"Dennis Lee Bieber" <wlfraed@ix.netcom.com> wrote in message news:1j1ebalmgkuskq0ltnv5m4sbm6d3p5f840@4ax.com... > > Pseudo (Python 2.x) code > > def aThread(delay=600.0): #default 10 minutes > while keepRunning: > print "thread triggered at %s" % time.time() > time.sleep(delay) > print "thread was commanded to exit" I read a variation on this theme some years ago that uses event.wait(timeout=delay) to manage the delay. >From the docs, "block until another thread calls set() to set the flag to true, or until the optional timeout occurs." The benefit is that setting the flag terminates the loop straight away, as opposed to waiting for the sleep to finish. I can show some sample code if anyone is interested. Frank Millman
Back to top | Article view | comp.lang.python
csiph-web