Skip to content

04 web_scraping asyncio.create_task don't exist #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
NissesSenap opened this issue Oct 5, 2018 · 3 comments
Closed

04 web_scraping asyncio.create_task don't exist #5

NissesSenap opened this issue Oct 5, 2018 · 3 comments

Comments

@NissesSenap
Copy link

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

@mikeckennedy
Copy link
Member

What version of Python are you using?

@mikeckennedy
Copy link
Member

You can call create_task on the loop object rather than on the asyncio module as well. Give that a try.

@mikeckennedy
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants