Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed1a.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.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'socket': 0.07; 'apis': 0.09; 'objects,': 0.09; 'cc:addr:python-list': 0.11; 'wrote': 0.14; 'posted': 0.15; 'blocking': 0.16; 'c-level': 0.16; 'done),': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'mode,': 0.16; 'non-blocking': 0.16; 'appropriate': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'backend': 0.19; "python's": 0.19; 'cc:addr:python.org': 0.22; "haven't": 0.24; 'cc:2**0': 0.24; 'nearly': 0.26; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'correct': 0.29; 'rest': 0.29; 'am,': 0.29; 'start,': 0.30; 'message-id:@mail.gmail.com': 0.30; 'getting': 0.31; 'easier': 0.31; 'operations.': 0.31; 'fri,': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'data,': 0.36; 'library.': 0.36; 'should': 0.36; 'level': 0.37; 'sure': 0.39; 'how': 0.40; 'new': 0.61; 'matter': 0.61; 'high': 0.63; 'happen': 0.63; 'details': 0.65; 'engage': 0.74; 'promptly': 0.84; 'dealt': 0.91; 'to:none': 0.92 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=3ZPLGFb+36eRZVYcYlp/8X/cLad3sV3YmYe88Zw/kHw=; b=j0qN2e2RhRj5jnksrOIQXNvsg6GJEyoONaFBRVKMwz9VOh64USHAbtchTP9q77pCox Q8/xquMiZUPDNmRv1vE6TUAV6WqmI+5qXTP+YQE7URiQiVARwVvGiWhhYmM1XeTKGm1+ KdOtc2uBcwDbuh9AjokIGGNfkCVx+nmDmvstLKMxjyZEp0kQim7Mxs2SHHM8QtRKySvh QZ2LP7R2mofxI+nd5nCuF60yXAa0VwDHlzHvDJNx6bovORS/6mjixfAJOeyeP9vaqUDf +CRQ/PqF9yhd6G5BNcemxYykVqmYhB8O2qZpPmB2Q6kLI2fPrFUeZTRezsAo3frqCSd5 bKsQ== MIME-Version: 1.0 X-Received: by 10.66.102.39 with SMTP id fl7mr20401877pab.43.1397143976898; Thu, 10 Apr 2014 08:32:56 -0700 (PDT) In-Reply-To: <450892781418836111.682065sturla.molden-gmail.com@news.gmane.org> References: <87wqexmmuc.fsf@elektro.pacujo.net> <450892781418836111.682065sturla.molden-gmail.com@news.gmane.org> Date: Fri, 11 Apr 2014 01:32:56 +1000 Subject: Re: threading 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: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1397143980 news.xs4all.nl 2847 [2001:888:2000:d::a6]:44130 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:70044 On Fri, Apr 11, 2014 at 1:24 AM, Sturla Molden wrote: > And exactly how is getting all of this correct any easier than just using > threads and blocking i/o? For a start, nearly everything Marko just posted should be dealt with by your library. I don't know Python's asyncio as it's very new and I haven't yet found an excuse to use it, but with Pike, I just engage backend mode, set callbacks on the appropriate socket/file/port objects, and let things happen perfectly. All I need to do is check a few return values (eg if I ask a non-blocking socket to write a whole pile of data, it might return that it wrote only some of it, in which case I have to buffer the rest - not hard but has to be done), and make sure I always return promptly from my callbacks so as to avoid lagging out other operations. None of the details of C-level APIs matter to my high level code. ChrisA