Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #83797
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'true,': 0.05; '(python': 0.07; '%s"': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'terminates': 0.09; 'subject:How': 0.10; 'def': 0.12; 'wrote': 0.14; 'thread': 0.14; 'finish.': 0.16; 'optional': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'set()': 0.16; 'skip:n 50': 0.16; 'time.time()': 0.16; 'timeout': 0.16; 'print': 0.22; 'header:X-Complaints-To:1': 0.27; 'code': 0.31; 'subject:that': 0.31; 'anyone': 0.31; 'another': 0.32; 'ago': 0.33; 'subject:the': 0.34; 'opposed': 0.36; 'to:addr :python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'read': 0.60; 'show': 0.63; 'minutes': 0.67; 'sample': 0.67; 'benefit': 0.68; 'frank': 0.68; 'commanded': 0.84; 'delay.': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | "Frank Millman" <frank@chagford.com> |
| Subject | Re: How to terminate the function that runs every n seconds |
| Date | Thu, 15 Jan 2015 08:56:10 +0200 |
| References | <CACT3xuWvN=zUs5CmuxceG9yv2gPWkmxF2dTgWOr8WqmaJxag+A@mail.gmail.com> <CACT3xuUr-07yW-FjiKBjPbsbn5j7r1vUfu1E0A6Myz=7sYpnzA@mail.gmail.com> <54B69A5B.5000801@davea.name> <CACT3xuXSuXyRu8ReXLczFw9N_LEajQzDM=eccdU3GPmj4MgYLA@mail.gmail.com> <1j1ebalmgkuskq0ltnv5m4sbm6d3p5f840@4ax.com> |
| X-Gmane-NNTP-Posting-Host | 197.86.222.218 |
| X-MSMail-Priority | Normal |
| X-Newsreader | Microsoft Outlook Express 6.00.3790.4657 |
| X-RFC2646 | Format=Flowed; Original |
| X-MimeOLE | Produced By Microsoft MimeOLE V6.00.3790.4913 |
| 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.17742.1421304984.18130.python-list@python.org> (permalink) |
| Lines | 27 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1421304984 news.xs4all.nl 2848 [2001:888:2000:d::a6]:51290 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:83797 |
Show key headers only | View raw
"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 comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: How to terminate the function that runs every n seconds "Frank Millman" <frank@chagford.com> - 2015-01-15 08:56 +0200
csiph-web