Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'interpreter': 0.05; 'debug': 0.07; 'high-level': 0.09; 'properly.': 0.09; 'subject:script': 0.09; 'wrong,': 0.09; 'python': 0.11; 'thread': 0.14; 'downside': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'headaches': 0.16; 'interacting,': 0.16; 'roy': 0.16; 'sorts': 0.16; 'subject:versus': 0.16; 'language': 0.16; 'wrote:': 0.18; 'memory': 0.22; 'handles': 0.22; 'header:In-Reply- To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'another': 0.32; '(i.e.': 0.33; 'continuing': 0.33; 'fri,': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'two': 0.37; 'problems': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'problems.': 0.60; 'simple': 0.61; 'more': 0.64; 'smith': 0.68; 'sharing': 0.69; 'allocation': 0.74; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=7mS4Nsqb/O6IjYIAP1KQ4eHSFPGbRc6s7xGBiq59/pM=; b=IUJXu13eD5pjq5k9/nIa5VOfj5AQdJPMwCkka7JHo1k1oUgZ9OPcdnduKcd/j+Kl1r alG56IiZ0zfpDXo86r8ttVxia/hmoDQip3976EcRVpq9hjXYKAvhF2xGTGDYu8TEpZwF RjYt1W6Ml/lCo1tLULnd8zcVNAy9OGjMfPtfbjFqB58OWi4mBd9jGxlbQ0fteNK0wDRa QfGdLFdEOZcYnW6w5mQQHGlZsVlhJAXy4uLNiNghpr7wzwuj11VHWhlaBSuXN8mSYroP HD7RT+XkporDjJN9aGvjomhIi9kkMtYQm2Zdq+UCRq2ZGUC19kv4ubOqPUJjMy+m+7Qr zt5A== MIME-Version: 1.0 X-Received: by 10.68.125.226 with SMTP id mt2mr1577824pbb.115.1380819000185; Thu, 03 Oct 2013 09:50:00 -0700 (PDT) In-Reply-To: References: Date: Fri, 4 Oct 2013 02:50:00 +1000 Subject: Re: Multiple scripts versus single multi-threaded script 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: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1380819470 news.xs4all.nl 15908 [2001:888:2000:d::a6]:51883 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:55424 On Fri, Oct 4, 2013 at 2:41 AM, Roy Smith wrote: > The downside to threads is that all of of this sharing makes them much > more complicated to use properly. You have to be aware of how all the > threads are interacting, and mediate access to shared resources. If you > do that wrong, you get memory corruption, deadlocks, and all sorts of > (extremely) difficult to debug problems. A lot of the really hairy > problems (i.e. things like one thread continuing to use memory which > another thread has freed) are solved by using a high-level language like > Python which handles all the memory allocation for you, but you can > still get deadlocks and data corruption. With CPython, you don't have any headaches like that; you have one very simple protection, a Global Interpreter Lock (GIL), which guarantees that no two threads will execute Python code simultaneously. No corruption, no deadlocks, no hairy problems. ChrisA