Path: csiph.com!usenet.pasdenom.info!poup.poupinou.org!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!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.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; '(even': 0.05; 'interpreter': 0.05; 'context': 0.07; 'interpreter.': 0.07; 'subject:help': 0.08; 'back.': 0.09; 'interpreted': 0.09; 'python': 0.11; 'thread': 0.14; '"every': 0.16; 'bytecode': 0.16; 'check.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'wrote:': 0.18; 'mon,': 0.24; 'versions': 0.24; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'another': 0.32; 'subject:with': 0.35; 'common': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'done,': 0.36; 'raising': 0.36; 'done': 0.36; 'level': 0.37; 'implement': 0.38; 'ahead': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'easy': 0.60; 'signal': 0.60; 'lower': 0.61; 'making': 0.63; '20,': 0.68; 'default': 0.69; '100': 0.79; 'interrupt': 0.84; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=FOqUghG2ZAGEziNp90w85Y9YxDrxCZWC0tTp8KerTf4=; b=a5Rl5dH5hJiRlwxbERZ7NOmWmByinFB32Yh80QmYR5h8pV2+KmvY3eURw4+AdNNzYe GLnvU2nh4zLB5A9e4Q2BBpK2NLZjuLYCJMbQymHpNSRHINeeFwf+5WbAgg9NXFX1AMv9 vE1QRQ0sd0PwhJ7hNyDhbhKc23J7rKt6jipzIeUj4tDiYZMbFNnmjv7nsIiJ0/2AOUia qNql7UqMDyPC3U1QjW8he9N+QVwLVGTyGSHPlGVAksYcG9GV3IKljj41/TVYwO+ArsBw bmmjp7eWzhLucLoKy4E/PwV/c3R3EhYrgnbsfoX/+5lOt65jTKWAo+k3IaCY847/8bQp mpbg== MIME-Version: 1.0 X-Received: by 10.52.175.200 with SMTP id cc8mr28281601vdc.94.1369000343943; Sun, 19 May 2013 14:52:23 -0700 (PDT) In-Reply-To: References: <7baacf5a-0c50-4935-ad5b-148c208d759b@googlegroups.com> <13lfp8lds6e2e41rtsnvqimcb6inu7p28o@invalid.netcom.com> Date: Mon, 20 May 2013 07:52:23 +1000 Subject: Re: Please help with Threading From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1369000346 news.xs4all.nl 15909 [2001:888:2000:d::a6]:44045 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:45567 On Mon, May 20, 2013 at 7:46 AM, Dennis Lee Bieber wrote: > On Sun, 19 May 2013 10:38:14 +1000, Chris Angelico > declaimed the following in gmane.comp.python.general: >> With interpreted code eg in CPython, it's easy to implement preemption >> in the interpreter. I don't know how it's actually done, but one easy >> implementation would be "every N bytecode instructions, context >> switch". It's still done at a lower level than user code (N bytecode > > Which IS how the common Python interpreter does it -- barring the > thread making some system call that triggers a preemption ahead of time > (even time.sleep(0.0) triggers scheduling). Forget if the default is 20 > or 100 byte-code instructions -- as I recall, it DID change a few > versions back. Incidentally, is the context-switch check the same as the check for interrupt signal raising KeyboardInterrupt? ISTR that was another "every N instructions" check. ChrisA