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


Groups > comp.lang.python > #103454

Re: [Python-ideas] How the heck does async/await work in Python 3.5

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Ian Kelly <ian.g.kelly@gmail.com>
Newsgroups comp.lang.python
Subject Re: [Python-ideas] How the heck does async/await work in Python 3.5
Date Wed, 24 Feb 2016 09:47:41 -0700
Lines 41
Message-ID <mailman.101.1456332509.20994.python-list@python.org> (permalink)
References <mailman.224.1455746935.22075.python-list@python.org> <56c7d145$0$1597$c3e8da3$5496439d@news.astraweb.com> <na92c0$n65$1@dont-email.me> <56CCC98C.5060504@mail.de> <CAH0mxTQE9xn3OZJ8s-oj13LtQOYGGW2Y1uC9xM3YpzAtY8pqJQ@mail.gmail.com> <CAMpsgwbO1v7318u9VZCTrPHOERAAQiEAHJ9ChWCVqYP-7aqskw@mail.gmail.com> <mailman.95.1456326057.20994.python-list@python.org> <87vb5ejfnv.fsf@elektro.pacujo.net> <mailman.97.1456328534.20994.python-list@python.org> <87r3g2jdcb.fsf@elektro.pacujo.net>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de I0Sp1cX9qunodUpJzd16xwWU3tJHJERTlqGvU87Fs7NA==
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.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'subject:: [': 0.03; 'received:209.85.223': 0.03; 'subject:Python': 0.05; 'subject:How': 0.09; 'def': 0.13; 'wed,': 0.15; 'skip:p 40': 0.15; '2016': 0.16; '24,': 0.16; '9:13': 0.16; 'data)': 0.16; 'reasonable.': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:ideas': 0.16; 'write.': 0.16; 'wrote:': 0.16; 'skip:l 30': 0.18; 'subject:] ': 0.19; '>>>': 0.20; 'work,': 0.21; 'am,': 0.23; 'feb': 0.23; 'tried': 0.24; 'header:In-Reply-To:1': 0.24; "doesn't": 0.26; 'point.': 0.27; 'message-id:@mail.gmail.com': 0.27; 'subject:/': 0.30; "i'd": 0.31; 'skip:_ 10': 0.32; 'point': 0.33; 'class': 0.33; 'curious': 0.33; 'received:google.com': 0.35; 'quite': 0.35; 'something': 0.35; "isn't": 0.35; 'there': 0.36; 'received:209.85': 0.36; 'subject:work': 0.36; 'to:addr:python- list': 0.36; 'missing': 0.37; 'seem': 0.37; 'received:209': 0.38; 'wrong': 0.38; 'anything': 0.38; 'test': 0.39; 'subject:the': 0.39; 'subject:-': 0.39; 'to:addr:python.org': 0.40; 'ever': 0.60; 'skip:u 10': 0.61; '20,': 0.66; 'benchmark': 0.84; 'influencing': 0.84; 'tem': 0.84; 'to:name:python': 0.84; 'urge': 0.91
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; bh=4zSCwUtFXnRX4L/89NtEXNFMnic+HvugFaIhGNtKOrU=; b=vHCooFREr+EOMKvzdtYGVbZu2jdqLfzsDnZfZcuN2DrKN/rzcB8t7Q4aiiBHOQPgzn RbakD7tq0FctjE8aukZ1D3lA4ggs2zJGEWrvcYBvVjgLeY5UjTgA9+fnnPleog+DcFg8 oaptUcwCuj/YQUm+OjPZ5jR6UKD0DlwcEs7d7xk9A87P5JAgztqpwXoIJHmqPQ3G0w8L +fXyPrSddD9qvBGRvCeYySaNeqxM0lQVg/UgzM54olXVQ2DHmDzb6t4y6TI1yniEubvQ 6HNzPcy1PXumJXmLCpm74xHujUKOmzSFynhoiZN9pcAGdabmxS1zw31xPTaGKNf93AId uerQ==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type; bh=4zSCwUtFXnRX4L/89NtEXNFMnic+HvugFaIhGNtKOrU=; b=inkZ3byYi/zZAcgzi+E+r6Qg5+awRcPM6DkBYtdJbT4OLTJs3ic5M+37yVzrx5zfSW ZfqiGRB+m1ysYuMK8KiKsiqzph8Ph4RIiDlH977fa4Q2bufjJ3ACdydGr5wTo9pI1aUx QnIW9YUPsXIi+A8jlNR9vQrrm8/Zmj88QTYmBfca7LH5F0/sdVb5//7u40tBXTombdzu i4BVb22BkMWqOLwITDaKZvtoiKtlTHf/MpQjWPayjfldHeVc10MzhDpCrCT7BzGLsDpz dcnMD2vajn1lb9Xexl1/GBIBirvYzfvw+aT0Pif5IX0COINRLh2z0v5LhQkbW7c6yAVS aIJg==
X-Gm-Message-State AG10YOQDFB5jJwZPVVGAwo35NHRG0kXbMvrywhcyqGxTWpAFyx1m5J0CWebuD+8wnF5tEimdkSpJ3ORqN2pACA==
X-Received by 10.107.19.90 with SMTP id b87mr44267807ioj.11.1456332500511; Wed, 24 Feb 2016 08:48:20 -0800 (PST)
In-Reply-To <87r3g2jdcb.fsf@elektro.pacujo.net>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.21rc2
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>
Xref csiph.com comp.lang.python:103454

Show key headers only | View raw


On Wed, Feb 24, 2016 at 9:13 AM, Marko Rauhamaa <marko@pacujo.net> wrote:
> Ian Kelly <ian.g.kelly@gmail.com>:
>
>> On Wed, Feb 24, 2016 at 8:23 AM, Marko Rauhamaa <marko@pacujo.net> wrote:
>>> Tem Pl <rtempl31@gmail.com>:
>>>> Is there something wrong with this implementation?
>>>
>>> It's a "fork bomb".
>>
>> Isn't that the point of the benchmark?
>
> I don't quite see the point of the program as it doesn't resemble
> anything I'd ever have an urge to write.

That's reasonable. asyncio is designed for I/O-bound work, so a fair
response to the benchmark is that subjecting it to a CPU-bound stress
test is perhaps missing the point.

I was curious about how much the selector-based event loop might be
influencing the timing, so I tried instrumenting the selector.

class ProfiledSelector(selectors.DefaultSelector):
    def __init__(self):
        super().__init__()
        self._calls = collections.Counter()
    def select(self, timeout=None):
        self._calls['select'] += 1
        return super().select(timeout)
    def register(self, fileobj, events, data=None):
        self._calls['register'] += 1
        return super().register(fileobj, events, data)

selector = ProfiledSelector()
loop = asyncio.SelectorEventLoop(selector)
asyncio.set_event_loop(loop)
loop.run_until_complete(coroutine())
# 499999500000
selector._calls
# Counter({'select': 20, 'register': 1})

Only 20 iterations of the event loop? That doesn't seem unreasonable.

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


Thread

How the heck does async/await work in Python 3.5 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-02-17 22:08 +0000
  Re: How the heck does async/await work in Python 3.5 Steven D'Aprano <steve@pearwood.info> - 2016-02-20 13:36 +1100
    Re: How the heck does async/await work in Python 3.5 Rustom Mody <rustompmody@gmail.com> - 2016-02-19 21:24 -0800
      Re: How the heck does async/await work in Python 3.5 Rustom Mody <rustompmody@gmail.com> - 2016-02-19 21:34 -0800
        Re: How the heck does async/await work in Python 3.5 Paul Rubin <no.email@nospam.invalid> - 2016-02-19 22:44 -0800
          Re: How the heck does async/await work in Python 3.5 Steven D'Aprano <steve@pearwood.info> - 2016-02-21 18:17 +1100
            Re: How the heck does async/await work in Python 3.5 Paul Rubin <no.email@nospam.invalid> - 2016-02-20 23:34 -0800
      Re: How the heck does async/await work in Python 3.5 Ian Kelly <ian.g.kelly@gmail.com> - 2016-02-20 00:48 -0700
      Re: How the heck does async/await work in Python 3.5 Chris Angelico <rosuav@gmail.com> - 2016-02-20 18:57 +1100
      Re: How the heck does async/await work in Python 3.5 Ian Kelly <ian.g.kelly@gmail.com> - 2016-02-20 01:14 -0700
      Re: How the heck does async/await work in Python 3.5 Chris Angelico <rosuav@gmail.com> - 2016-02-20 19:49 +1100
      Re: How the heck does async/await work in Python 3.5 Ian Kelly <ian.g.kelly@gmail.com> - 2016-02-20 02:11 -0700
      Re: How the heck does async/await work in Python 3.5 Ian Kelly <ian.g.kelly@gmail.com> - 2016-02-20 02:21 -0700
    Re: How the heck does async/await work in Python 3.5 Christian Gollwitzer <auriocus@gmx.de> - 2016-02-20 07:53 +0100
      Re: How the heck does async/await work in Python 3.5 "Sven R. Kunze" <srkunze@mail.de> - 2016-02-22 23:16 +0100
      Re: How the heck does async/await work in Python 3.5 Ian Kelly <ian.g.kelly@gmail.com> - 2016-02-22 17:48 -0700
      Re: How the heck does async/await work in Python 3.5 "Sven R. Kunze" <srkunze@mail.de> - 2016-02-23 17:50 +0100
      Re: How the heck does async/await work in Python 3.5 Ian Kelly <ian.g.kelly@gmail.com> - 2016-02-23 10:37 -0700
      Re: How the heck does async/await work in Python 3.5 "Sven R. Kunze" <srkunze@mail.de> - 2016-02-23 20:42 +0100
      Re: How the heck does async/await work in Python 3.5 "Sven R. Kunze" <srkunze@mail.de> - 2016-02-23 22:05 +0100
      Re: [Python-ideas] How the heck does async/await work in Python 3.5 "Joao S. O. Bueno" <jsbueno@python.org.br> - 2016-02-23 18:25 -0300
      Re: [Python-ideas] How the heck does async/await work in Python 3.5 Paul Moore <p.f.moore@gmail.com> - 2016-02-24 09:59 +0000
      Re: [Python-ideas] How the heck does async/await work in Python 3.5 Victor Stinner <victor.stinner@gmail.com> - 2016-02-24 11:01 +0100
      Re: [Python-ideas] How the heck does async/await work in Python 3.5 王珺 <wjun77@gmail.com> - 2016-02-24 18:40 +0800
        Re: [Python-ideas] How the heck does async/await work in Python 3.5 Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-02-25 10:00 +1300
          Re: [Python-ideas] How the heck does async/await work in Python 3.5 王珺 <wjun77@gmail.com> - 2016-02-25 08:40 +0800
          Re: [Python-ideas] How the heck does async/await work in Python 3.5 Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-02-24 20:37 -0500
      Re: [Python-ideas] How the heck does async/await work in Python 3.5 Tem Pl <rtempl31@gmail.com> - 2016-02-24 06:39 -0800
        Re: [Python-ideas] How the heck does async/await work in Python 3.5 Marko Rauhamaa <marko@pacujo.net> - 2016-02-24 17:23 +0200
          Re: [Python-ideas] How the heck does async/await work in Python 3.5 Ian Kelly <ian.g.kelly@gmail.com> - 2016-02-24 08:41 -0700
            Re: [Python-ideas] How the heck does async/await work in Python 3.5 Marko Rauhamaa <marko@pacujo.net> - 2016-02-24 18:13 +0200
              Re: [Python-ideas] How the heck does async/await work in Python 3.5 Ian Kelly <ian.g.kelly@gmail.com> - 2016-02-24 09:47 -0700

csiph-web