Review my asyncio code

Yaşar Arabacı yasar11732 at gmail.com
Tue Jul 22 13:09:09 EDT 2014


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/



More information about the Python-list mailing list