Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!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.044 X-Spam-Evidence: '*H*': 0.91; '*S*': 0.00; 'callback': 0.09; 'latter': 0.09; 'properly.': 0.09; 'cc:addr:python-list': 0.11; 'thread': 0.14; "'connection": 0.16; 'blocking': 0.16; 'event-driven': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'log?': 0.16; 'logging,': 0.16; 'non-blocking': 0.16; 'threads,': 0.16; 'wrote:': 0.18; 'work,': 0.20; 'written': 0.21; 'programming': 0.22; 'cc:addr:python.org': 0.22; 'error': 0.23; 'cc:2**0': 0.24; 'compare': 0.26; 'possibly': 0.26; 'header:In- Reply-To:1': 0.27; 'compared': 0.30; 'database,': 0.30; 'message- id:@mail.gmail.com': 0.30; 'request,': 0.31; 'anywhere': 0.35; 'connection': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'pm,': 0.38; 'does': 0.39; 'how': 0.40; 'even': 0.60; 'simply': 0.61; 'grab': 0.64; 'more': 0.64; 'occur': 0.65; 'air': 0.66; 'frank': 0.68; 'potentially': 0.81; 'asynchronous': 0.84; 'common,': 0.84; 'etc,': 0.84; 'response,': 0.91; 'to:none': 0.92; 'connection,': 0.95 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:cc :content-type; bh=HBEz/k994xTgbDfHQF/6wNB2ax5yPgHH5vMeNGoF3YQ=; b=DcQrWtuAtlmlJJqNrauVs0PbCEunOhskrIhZ7VOprdy/ODbV5oTeKShvZSBK2UzjIf J0IvVRQGQ1cY83elLthw4BiwnDuxeztLXM+iRS5Plfq8DWl3PkYB1XbrbRqiWaHfmtJM fn8MbzusmsB6ueIOZuQ4WugJLqIPDUa1gr7DDnkxJnqvRrEqGLD4HVQFXEBm+zsUySjx icg9BkhJmU9VKMK2uVdjNdF5RTOfFCO9nI2CKBHofdB0Gpkw2rmJ/nxJRZWXNh7yf3oi 9cB4BjZhEj8FHsLFgKRQeQs/81gAbSk0m9XG4tjQT0OnAtMzado9tiA7Tmxxya+U0ZbF lgfQ== MIME-Version: 1.0 X-Received: by 10.58.237.199 with SMTP id ve7mr910918vec.66.1401796894294; Tue, 03 Jun 2014 05:01:34 -0700 (PDT) In-Reply-To: References: <874n03t5t9.fsf@elektro.pacujo.net> <7x4n03dor0.fsf@ruckus.brouhaha.com> <878upe8poc.fsf@elektro.pacujo.net> Date: Tue, 3 Jun 2014 22:01:34 +1000 Subject: Re: Benefits of asyncio From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 1401796902 news.xs4all.nl 2911 [2001:888:2000:d::a6]:34270 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:72510 On Tue, Jun 3, 2014 at 9:09 PM, Frank Millman wrote: > So why not keep a 'connection pool', and for every potentially blocking > request, grab a connection, set up a callback or a 'yield from' to wait for > the response, and unblock. Compare against a thread pool, where each thread simply does blocking requests. With threads, you use blocking database, blocking logging, blocking I/O, etc, and everything *just happens*; with a connection pool, like this, you need to do every single one of them separately. (How many of you have ever written non-blocking error logging? Or have you written a non-blocking system with blocking calls to write to your error log? The latter is far FAR more common, but all files, even stdout/stderr, can block.) I don't see how Marko's assertion that event-driven asynchronous programming is a breath of fresh air compared with multithreading. The only way multithreading can possibly be more complicated is that preemption can occur anywhere - and that's exactly one of the big flaws in async work, if you don't do your job properly. ChrisA