Closed NissesSenap closed 5 years ago
What version of Python are you using?
You can call create_task on the loop object rather than on the asyncio module as well. Give that a try.
I just tried this on 3.6 and got the same error as you. But works fine under 3.7. So I updated the code to work on 3.6 too.
Hi
Don't understand how it works for you in the demo but when i run it crases straight away. I have tried multiple times and when i try to start 04-asyncio/web_scraping/async_scrape/program.py i get the following error.
python program.py Traceback (most recent call last): File "program.py", line 58, in
main()
File "program.py", line 32, in main
loop.run_until_complete(get_title_range())
File "/usr/lib/python3.6/asyncio/base_events.py", line 468, in run_until_complete
return future.result()
File "program.py", line 49, in get_title_range
tasks.append((n, asyncio.create_task(get_html(n))))
AttributeError: module 'asyncio' has no attribute 'create_task'
Using pipenv: aiodns==1.1.1 aiohttp==3.4.4 async-timeout==3.0.0 attrs==18.2.0 beautifulsoup4==4.6.3 bs4==0.0.1 cchardet==2.1.4 chardet==3.0.4 colorama==0.3.9 idna-ssl==1.1.0; python_version < '3.7' idna==2.7 multidict==4.4.2 pycares==2.3.0 yarl==1.2.6
python --version Python 3.6.6