Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: asyncio - run coroutine in the background Date: Sat, 20 Feb 2016 19:52:15 +1100 Lines: 15 Message-ID: References: <8737sumpjl.fsf@elektro.pacujo.net> <87h9ha8lt0.fsf@jester.gateway.pace.com> <87d1rwpwo2.fsf@elektro.pacujo.net> <87r3gc608i.fsf@elektro.pacujo.net> <871t877ru6.fsf@jester.gateway.pace.com> <87oabbpzoo.fsf@elektro.pacujo.net> <87twl36amj.fsf@jester.gateway.pace.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de JFtLEnCCq3BF7i4+rFMryg5//2/MsTS790UIrAi3bmCw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'skip:/ 10': 0.07; 'cc:addr :python-list': 0.09; 'caching,': 0.09; 'lookup': 0.09; '2016': 0.16; 'async': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'getaddrinfo': 0.16; 'hacked': 0.16; 'ignores': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:run': 0.16; 'twisted': 0.16; 'version?': 0.16; 'wrote:': 0.16; 'library': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'feb': 0.23; 'sat,': 0.23; 'header:In-Reply-To:1': 0.24; 'paul': 0.24; '(which': 0.26; 'message-id:@mail.gmail.com': 0.27; 'regular': 0.29; 'server.': 0.30; 'handle': 0.34; 'gives': 0.35; 'received:google.com': 0.35; 'but': 0.36; 'should': 0.36; 'instead': 0.36; 'received:209.85': 0.36; 'possible': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:209.85.213': 0.37; 'version': 0.38; 'received:209': 0.38; 'goes': 0.39; 'does': 0.39; 'subject:the': 0.39; 'notified': 0.62; '20,': 0.66; 'chrisa': 0.84; 'pain': 0.84; 'to:none': 0.91; 'notorious': 0.91 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=SRPiZ2/3he9gYqvgsasWmtODf0NqOtqZlhcj4Exeh0E=; b=Q1DJel75wdPlzZjPFQGlmXtdLK/fddmV8RMYmGS0/BgZt3wFuVYKSbh1x0u84eoS0N pMEou/uTYqJ0qgGSTVVe9gYKrg9dXk57/3UeJxMa1xPfpxW5f88i0Rw1qpJR39n/TFty wQvaQNnIJRW+1GnDqyPi22/g9Vm9JA/Gg/7OlfYoHCw11ALf7ebUZ7hqKAjXbO83j+JM L368GglEglWznkUKdd8dsw5vBng7ijMn+JfdXkLW1UjAYALPYbMSQEMjXes2GiDOcZM4 r2F8aoswV8KZTlEo3ZgDDMkh03eSKhMKTb0da7BhciIoMkGV1Y6UYqZj4Gvez041lPwu 04Ig== 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:date :message-id:subject:from:cc:content-type; bh=SRPiZ2/3he9gYqvgsasWmtODf0NqOtqZlhcj4Exeh0E=; b=THnzT3B0Af1xoROix6+QVpyjpjZwd8JdqK4unh6IKWk+yUFyKGml56QIIQD2SCvhw0 lnCYr7bqDfv8VwmpJ6PuH/VuZR/CNl8hNp/n+CwjzOJcY9QmwTy/wZM4YoKMk+iWHgph nLmWIpZ9dboJC8XRrNglUEZNZgdudwvYnGKeGfKpDcqyJLzImMkFZc1P6TNn8AMcdtL8 Grk7aOsLBfBAUQT9c4c+uTDFMq0ORi+V4IhFpznJf/ALZFJv3G7znu5QI0rj3mRpgIuB VyAOW/+IsrJCrZcuj5EJvX9a+a8v49eyQvHY49dTtjOBCwL9hqWmMMdQhyn9bm3fnuga Tvgg== X-Gm-Message-State: AG10YOTFgSazDNgER2GH26jkb8CEEfriJmvBq446k0MMPqQTQAerF3xYzua1R24Hv+hnif6OSxOY9RK+VYOKEg== X-Received: by 10.50.57.11 with SMTP id e11mr1264367igq.13.1455958336092; Sat, 20 Feb 2016 00:52:16 -0800 (PST) In-Reply-To: <87twl36amj.fsf@jester.gateway.pace.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21rc2 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:103256 On Sat, Feb 20, 2016 at 7:37 PM, Paul Rubin wrote: > getaddrinfo is a notorious pain but I think it's just a library issue; > an async version should be possible in principle. How does Twisted > handle it? Does it have a version? In a (non-Python) program of mine, I got annoyed by synchronous name lookups, so I hacked around it: instead of using the regular library functions, I just do a DNS lookup directly (which can then be event-based - send a UDP packet, get notified when a UDP packet arrives). Downside: Ignores /etc/nsswitch.conf and /etc/hosts, and goes straight to the name server. Upside: Is able to do its own caching, since the DNS library gives me the TTLs, but gethostbyname/getaddrinfo won't. ChrisA