Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2a.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'linux,': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:How': 0.10; 'jan': 0.12; 'thread': 0.14; 'blocked': 0.16; 'data...': 0.16; 'message-id:@4ax.com': 0.16; 'non-blocking': 0.16; 'quit.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'windows?': 0.16; 'library': 0.18; 'thu,': 0.19; 'url:home': 0.24; 'header:X-Complaints-To:1': 0.27; 'function': 0.29; "doesn't": 0.30; 'subject:that': 0.31; 'maybe': 0.34; 'subject:the': 0.34; "can't": 0.35; '+0200,': 0.36; 'charset:us- ascii': 0.36; 'received:76': 0.38; 'to:addr:python-list': 0.38; 'short': 0.38; 'anything': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'signal': 0.60; 'telling': 0.64; '2015': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: How to terminate the function that runs every n seconds Date: Thu, 15 Jan 2015 09:11:54 -0500 Organization: IISS Elusive Unicorn References: <54B69A5B.5000801@davea.name> <87r3uwpetd.fsf@elektro.pacujo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: adsl-76-249-24-142.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: YES 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: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1421331127 news.xs4all.nl 2843 [2001:888:2000:d::a6]:32924 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:83826 On Thu, 15 Jan 2015 11:34:54 +0200, Marko Rauhamaa declaimed the following: >Dennis Lee Bieber : > >> The main thing to consider is that "killing" a thread doesn't >> work well in Python. Instead the thread has to check for some signal >> telling it to quit. > >Alas, a thread can't check anything because it's blocked by I/O. > My response to that then is: design the thread's I/O so that it is not blocking... On Linux, maybe a timed select(); Windows? short sleeps around a non-blocking check for available data... (if console I/O, msvcrt.kbhit(); otherwise may need some other library function to put a time-out on the I/O) -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/