Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.049 X-Spam-Evidence: '*H*': 0.90; '*S*': 0.00; 'subject:code': 0.07; 'finished.': 0.09; 'http': 0.09; 'pointers': 0.09; 'url:github': 0.09; 'wrote': 0.14; 'thread,': 0.16; 'url:py': 0.16; 'fix': 0.17; 'trying': 0.19; 'later': 0.20; 'code,': 0.22; 'necessary.': 0.24; 'together.': 0.24; 'wondering': 0.29; 'appreciated.': 0.29; 'especially': 0.30; 'message-id:@mail.gmail.com': 0.30; 'lines': 0.31; '(unless': 0.31; 'class': 0.32; 'run': 0.32; 'quite': 0.32; 'could': 0.34; 'problem': 0.35; "can't": 0.35; 'done.': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'module.': 0.36; 'method': 0.36; 'hi,': 0.36; 'too': 0.37; 'checks': 0.38; 'tasks': 0.38; 'to:addr:python-list': 0.38; 'that,': 0.38; 'guidance': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'utilize': 0.61; 'new': 0.61; 'from:charset:utf-8': 0.61; 'making': 0.63; 'guarantee': 0.63; 'results': 0.69; 'links,': 0.74; 'url:master': 0.84; 'ultimate': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=TOEBB089muqlJdaWsZZS4+xgA11Q4GhkSrxpazCYb5E=; b=i6663vU8RUK0686Jwg+o4WN358dCRzGrvEP6c/J1H4N/xVsmxJtwWDaMAkMeAgpJNS pvvy0v9a6q4QD8RGyOSkmgZJ2EreIjGoRzjAQtY14Ewp4+aKNpnD374I9d5f5x3eCpJc eWBsdS5YTaiBe8ZwZwZDsPdhULpSRt+pcPcDOzFgwQaisGkh3ByRo/w42Sq/9vjOkEIG DH+ePIjOS0RuWSZeiOx97vWjv6BDWMI+u4OAXs0j1cqrrK8P/BBRvDpNWPTmivhBmIaI cqVFcqmBeXJsuxjfL1ov0Quaxt2RwYaaePJ6TecZDED11UgITxF3Pz3UcKw01UHfWfRZ xUNQ== MIME-Version: 1.0 X-Received: by 10.236.172.161 with SMTP id t21mr53213324yhl.65.1406048949535; Tue, 22 Jul 2014 10:09:09 -0700 (PDT) Date: Tue, 22 Jul 2014 20:09:09 +0300 Subject: Review my asyncio code From: =?UTF-8?B?WWHFn2FyIEFyYWJhY8Sx?= To: 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: 34 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1406048959 news.xs4all.nl 2838 [2001:888:2000:d::a6]:59748 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:75006 Hi, I am trying to learn how to utilize aysncio module. In order to do that, I wrote a class that checks http status codes for all the pages on a given domain (unless there is no internal link pointing to it of course). Since it is too long to paste here, I uploaded it to my github repo, you can find it here; https://github.com/yasar11732/python-scripts/blob/master/asyncio-scripts/validate_links.py I was wondering if someone could review it and give me some pointers if necessary. The parts that I especially ask for guidance is firstly how I run my tasks in lines 40-48 I am adding new tasks as I found unvisited links, in line 132. The main problem I find with my code, but can't quite fix it yet, is that run method is blocking. But if I don't use a method like that, I don't know how I would guarantee that event loop is done. I thought about making the whole RecursiveStatusChecker class a Thread, but I am not sure how would Threads and asyncio work together. My ultimate aim with a class like that was to start it at some time, and check later whether or not new results are available or all the tasks are finished. Any help is appreciated. -- http://ysar.net/