Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #71123
| Path | csiph.com!usenet.pasdenom.info!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <andrew.l.mclean@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.008 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'model,': 0.05; 'cache': 0.07; '%s"': 0.09; 'bits': 0.09; 'indicates': 0.09; 'lookup': 0.09; 'separately': 0.09; 'subject:skip:c 10': 0.09; 'try:': 0.09; 'python': 0.11; 'from:addr:andrew': 0.16; 'here).': 0.16; 'it;': 0.16; 'tcp': 0.16; 'timeout': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'looked': 0.18; 'programming': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'error': 0.23; 'parse': 0.24; "haven't": 0.24; 'looks': 0.24; "i've": 0.25; 'handling': 0.26; 'query': 0.26; 'header:In-Reply-To:1': 0.27; 'record': 0.27; 'chris': 0.29; 'am,': 0.29; 'possibility': 0.29; 'scale': 0.29; 'andrew': 0.30; 'work.': 0.31; 'code': 0.31; 'getting': 0.31; 'easier': 0.31; 'requests': 0.31; 'probably': 0.32; 'option': 0.32; 'another': 0.32; 'addresses': 0.33; 'fri,': 0.33; 'maybe': 0.34; 'skip:d 20': 0.34; 'could': 0.34; 'except': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'false': 0.36; 'done': 0.36; 'doing': 0.36; "i'll": 0.36; 'possible': 0.36; 'url:org': 0.36; 'too': 0.37; 'starting': 0.37; 'being': 0.38; 'implement': 0.38; 'message-id:@gmail.com': 0.38; 'to:addr:python-list': 0.38; 'though,': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'easy': 0.60; 'most': 0.60; 'matter': 0.61; 'back': 0.62; 'address': 0.63; 'hear': 0.63; 'more': 0.64; 'benefit': 0.68; 'detail.': 0.68; 'past.': 0.68; 'default': 0.69; 'heavy': 0.81; 'asynchronous': 0.84; 'roads': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=0KzUsXNmY56Kem564M9JAxUw6tZbzULxI3SG2r/JLP4=; b=H6n8z3HoqanxPhXU3N/He7mqX+J5YEiHEDxq6leT0HhAcqFRMhvZlrLtzeSSoe5IGi pG7zaV6K+805g3VWxqNsVulRwXV4746WAH/R/QXPSbhEFOUEERN+jgxgID6djdRbmppF nlQ3JLyeC1nGBbclugwGBze9fCUP/MU9YgG3AsOhCLSZkqMdpY7ZhjcCRqmC/j3UuU9c Zu4R2EVNDqFPAjkK+TQhYTdbh7WChU8a3ubO/Hsfn8hY5QoH7c3gnnSJgGBb6TisStZv bEQPnzk8C53wGOh9NJ7zFfCwmXvB2LUKKGeklKCujOiLR5IeWv8pq0ZadE+bDwaqxdBl LTVw== |
| X-Received | by 10.180.9.202 with SMTP id c10mr4938882wib.7.1399577135852; Thu, 08 May 2014 12:25:35 -0700 (PDT) |
| Sender | Andrew McLean <andrew.l.mclean@gmail.com> |
| X-Google-Original-From | Andrew McLean <Andrew.L.McLean@gmail.com> |
| Date | Thu, 08 May 2014 20:25:43 +0100 |
| From | Andrew McLean <andrew@andros.org.uk> |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: Real-world use of concurrent.futures |
| References | <536BD338.4070004@andros.org.uk> <CAPTjJmpc_HeuyiqW=ZSo6cRp3wRBdLq6r2gDcNxh+-4sjNSx1A@mail.gmail.com> |
| In-Reply-To | <CAPTjJmpc_HeuyiqW=ZSo6cRp3wRBdLq6r2gDcNxh+-4sjNSx1A@mail.gmail.com> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | 7bit |
| 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.9795.1399577599.18130.python-list@python.org> (permalink) |
| Lines | 49 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1399577599 news.xs4all.nl 2965 [2001:888:2000:d::a6]:45305 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:71123 |
Show key headers only | View raw
On 08/05/2014 20:06, Chris Angelico wrote: > On Fri, May 9, 2014 at 4:55 AM, Andrew McLean <lists@andros.org.uk> wrote: >> Because of latency in the DNS lookup this could >> benefit from multithreading. > Before you go too far down roads that are starting to look > problematic: A DNS lookup is a UDP packet out and a UDP packet in > (ignoring the possibility of TCP queries, which you probably won't be > doing here). Maybe it would be easier to implement it as asynchronous > networking? I don't know that Python makes it easy for you to > construct DNS requests and parse DNS responses; that's something more > in Pike's line of work. But it may be more possible to outright do the > DNS query asynchronously. TBH I haven't looked into it; but it's > another option to consider. > > Separately from your programming model, though, how are you handling > timeouts? Any form of DNS error (NXDOMAIN being the most likely), and > the sort-of-error-but-not-error state of getting a response with no > answer, indicates that the address is invalid; but what if you just > don't hear back from the server? Will that mark addresses off as dead? > > ChrisA I've done this on a very small scale in the past. I used http://www.dnspython.org/ to do the heavy lifting. The relevant bits of code looks like: > # Set up the default dns resolver and add a cache > dns.resolver.default_resolver = dns.resolver.Resolver() > dns.resolver.default_resolver.cache = dns.resolver.Cache() and > try: > result = dns.resolver.query(domain, 'MX') > return True > except dns.resolver.NXDOMAIN: > return False > except dns.resolver.NoAnswer: > return False > except dns.resolver.Timeout: > print "*** timeout looking for the MX record for the domain: > %s" % domain > return False You are right, I'll need to do something more sophisticated when I encounter a timeout, but I think that's a matter of detail. Andrew
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Real-world use of concurrent.futures Andrew McLean <andrew@andros.org.uk> - 2014-05-08 20:25 +0100
csiph-web