Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #72438

Re: Benefits of asyncio

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 <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.026
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; 'essentially': 0.04; 'debug': 0.07; 'callback': 0.09; 'explanation': 0.09; 'idea?': 0.09; 'initiating': 0.09; 'pep': 0.09; 'python': 0.11; 'suggest': 0.14; 'btw': 0.16; "module's": 0.16; 'sequential': 0.16; 'tasks?': 0.16; 'wrote:': 0.18; 'library': 0.18; 'looked': 0.18; 'module': 0.19; 'trying': 0.19; 'normally': 0.19; 'thoughts': 0.19; 'example': 0.22; 'programming': 0.22; 'handles': 0.22; 'lets': 0.24; 'mon,': 0.24; 'looks': 0.24; 'task': 0.26; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'thus': 0.29; 'related': 0.29; '(like': 0.30; 'message-id:@mail.gmail.com': 0.30; '(which': 0.31; 'code': 0.31; 'url:wiki': 0.31; 'block,': 0.31; 'complete,': 0.31; 'initiate': 0.31; 'url:wikipedia': 0.31; 'anyone': 0.31; 'allows': 0.31; 'quite': 0.32; 'sense': 0.34; 'maybe': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'introducing': 0.36; 'url:org': 0.36; 'should': 0.36; 'to:addr:python-list': 0.38; 'does': 0.39; "couldn't": 0.39; 'weight': 0.39; 'to:addr:python.org': 0.39; 'called': 0.40; 'read': 0.60; 'simple': 0.61; "you're": 0.61; 'here:': 0.62; 'such': 0.63; 'more': 0.64; 'great': 0.65; 'between': 0.67; 'tasks.': 0.68; 'stated': 0.69; 'risk': 0.72; 'saw': 0.77; 'url:o': 0.78; 'asynchronous': 0.84; 'confusing': 0.84; 'existence.': 0.84; 'task,': 0.91; 'directly.': 0.95; 'race': 0.95
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=4PUeNl+ERbpdmnBeKG7R7kA2q03BXo4FIhHubLCgiys=; b=NOQELevx5KmbBAKWochbQhq4rWtxTpnRpmpab1b632whoE09gp6SAu5LMPKnRRvtdi j+Iyq8ZQ5DUnxMqFuFWUaVAebFINcqiJLWdZ0itf9/K36FYl5ZodTCcUAEy3JGMlciln wXabhYoS70zbTJqzPeKY0yVScdG9q0n8gk8Y6gm0NqvEDoT7AF/NYmb5RnnR4xG/Ze2K 1DdwwMxK2kcXQzEhn+v7z9kwrGgI3dpmcd8zGSUZeh0nvxKpJGCjApqO+9J+mEafPMfo sw8jxWRW6y+0nh5wZDIB4a+py/Cxwi2395PrF0FqtYBzu++mAX1JSzJM8lk8CLflExxl qvSg==
X-Received by 10.236.13.46 with SMTP id a34mr54737266yha.28.1401734315736; Mon, 02 Jun 2014 11:38:35 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <d1634744-39e8-4bfa-be76-1fd2292fd59f@googlegroups.com>
References <d1634744-39e8-4bfa-be76-1fd2292fd59f@googlegroups.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Mon, 2 Jun 2014 12:37:55 -0600
Subject Re: Benefits of asyncio
To Python <python-list@python.org>
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.10572.1401734686.18130.python-list@python.org> (permalink)
Lines 34
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1401734686 news.xs4all.nl 2956 [2001:888:2000:d::a6]:53113
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:72438

Show key headers only | View raw


On Mon, Jun 2, 2014 at 11:40 AM, Aseem Bansal <asmbansal2@gmail.com> wrote:
> I read in these groups that asyncio is a great addition to Python 3. I have looked around and saw the related PEP which is quite big BTW but couldn't find a simple explanation for why this is such a great addition. Any simple example where it can be used?
>
> It can be used to have a queue of tasks? Like threads? Maybe light weight threads? Those were my thoughts but the library reference clearly stated that this is single-threaded. So there should be some waiting time in between the tasks. Then what is good?
>
> These are just jumbled thoughts that came into my mind while trying to make sense of usefulness of asyncio. Anyone can give a better idea?

You're right, neither the PEP nor the docs to much to motivate the
module's existence. I suggest you start here:
http://en.wikipedia.org/wiki/Asynchronous_I/O

The asynchronous model lets you initiate a task (typically an I/O
task) that would normally block, and then go on to do other things
(like initiating more tasks) while waiting on that task, without
having to resort to multiple threads or processes (which have the
disadvantages of consuming more system resources as well as
introducing the risk of race conditions and deadlocks).

It does this by using callbacks; when a task is complete, a callback
is called that handles its completion.  Often in asynchronous code you
end up with large networks of callbacks that can be confusing to
follow and debug because nothing ever gets called directly.  One of
the significant features of the asyncio module is that it allows
asynchronous programming using coroutines, where the callbacks are
abstracted away and essentially have the effect of resuming the
coroutine when the task completes.  Thus you end up writing code that
looks a lot like threaded, sequential code with none of the pitfalls.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Benefits of asyncio Aseem Bansal <asmbansal2@gmail.com> - 2014-06-02 10:40 -0700
  Re: Benefits of asyncio Ian Kelly <ian.g.kelly@gmail.com> - 2014-06-02 12:37 -0600
  Re: Benefits of asyncio Terry Reedy <tjreedy@udel.edu> - 2014-06-02 16:07 -0400
    Re: Benefits of asyncio Roy Smith <roy@panix.com> - 2014-06-02 16:19 -0400
    Re: Benefits of asyncio Marko Rauhamaa <marko@pacujo.net> - 2014-06-02 23:28 +0300
      Re: Benefits of asyncio Paul Rubin <no.email@nospam.invalid> - 2014-06-02 13:45 -0700
        Re: Benefits of asyncio Chris Angelico <rosuav@gmail.com> - 2014-06-03 07:49 +1000
        Re: Benefits of asyncio Terry Reedy <tjreedy@udel.edu> - 2014-06-02 21:51 -0400
        Re: Benefits of asyncio Marko Rauhamaa <marko@pacujo.net> - 2014-06-03 09:36 +0300
          Re: Benefits of asyncio Chris Angelico <rosuav@gmail.com> - 2014-06-03 18:47 +1000
            Re: Benefits of asyncio Marko Rauhamaa <marko@pacujo.net> - 2014-06-03 12:10 +0300
              Re: Benefits of asyncio Chris Angelico <rosuav@gmail.com> - 2014-06-03 19:30 +1000
                Re: Benefits of asyncio Marko Rauhamaa <marko@pacujo.net> - 2014-06-03 13:08 +0300
                Re: Benefits of asyncio Chris Angelico <rosuav@gmail.com> - 2014-06-03 20:23 +1000
                Re: Benefits of asyncio Marko Rauhamaa <marko@pacujo.net> - 2014-06-03 14:12 +0300
                Re: Benefits of asyncio Paul Rubin <no.email@nospam.invalid> - 2014-06-04 00:52 -0700
              Re: Benefits of asyncio Burak Arslan <burak.arslan@arskom.com.tr> - 2014-06-03 14:05 +0300
              Re: Benefits of asyncio Chris Angelico <rosuav@gmail.com> - 2014-06-03 21:57 +1000
              Re: Benefits of asyncio Burak Arslan <burak.arslan@arskom.com.tr> - 2014-06-04 08:10 +0300
              Re: Benefits of asyncio Chris Angelico <rosuav@gmail.com> - 2014-06-04 17:30 +1000
              Re: Benefits of asyncio Paul Rubin <no.email@nospam.invalid> - 2014-06-04 00:48 -0700
          Re: Benefits of asyncio "Frank Millman" <frank@chagford.com> - 2014-06-03 13:09 +0200
          Re: Benefits of asyncio Chris Angelico <rosuav@gmail.com> - 2014-06-03 22:01 +1000
            Re: Benefits of asyncio Marko Rauhamaa <marko@pacujo.net> - 2014-06-03 16:05 +0300
              Re: Benefits of asyncio Chris Angelico <rosuav@gmail.com> - 2014-06-03 23:31 +1000
                Re: Benefits of asyncio Marko Rauhamaa <marko@pacujo.net> - 2014-06-03 16:42 +0300
                Re: Benefits of asyncio Chris Angelico <rosuav@gmail.com> - 2014-06-03 23:49 +1000
                Re: Benefits of asyncio Marko Rauhamaa <marko@pacujo.net> - 2014-06-03 19:18 +0300
              Re: Benefits of asyncio Roy Smith <roy@panix.com> - 2014-06-03 11:40 -0400
        Re: Benefits of asyncio Paul Sokolovsky <pmiscml@gmail.com> - 2014-06-03 11:31 +0300
  Re: Benefits of asyncio Burak Arslan <burak.arslan@arskom.com.tr> - 2014-06-03 00:07 +0300
  Re: Benefits of asyncio Aseem Bansal <asmbansal2@gmail.com> - 2014-06-02 21:54 -0700

csiph-web