4 thoughts on “Python Async basics video (100 million HTTP requests)”

  1. Hi, which version of python you’re using in this video?
    I got an error like this in Python 3.7.0 and Python 3.7.3:

    import asyncio
    async def mycoro(number):
    print(“Starting %d” % number)
    await asyncio.sleep(1)
    print(“Finishing %d” % number)
    return str(number)

    many = asyncio.gather(mycoro(1),mycoro(2),mycoro(3))

    Traceback (most recent call last):
    File “C:/xx/study.py”, line 13, in
    File “C:\Users\xxxx\Python\Python37-32\lib\asyncio\runners.py”, line 37, in run
    raise ValueError(“a coroutine was expected, got {!r}”.format(main))
    ValueError: a coroutine was expected, got

  2. Hi, it would have been 3.7.something. Try this:

    import asyncio
    async def mycoro(number):
        print("Starting %d" % number)
        await asyncio.sleep(1)
        print("Finishing %d" % number)
        return str(number)
    async def doit():
        return await asyncio.gather(mycoro(1),mycoro(2),mycoro(3))
    many = doit()

    Note the extra “await” before asyncio.gather.

    If that works, I think it’s a mistake I made translating 3.6 -> 3.7 – well spotted, and apologies!

  3. Hi Andy,

    This is best explanation so far I’ve been able to find for asyncio in a nutshell.. And I’ve been able to implement it in my small project, all thanks to you.

    I’ve encountered an issue though, while trying to use https proxies with my requests.

    It says, “ValueError: Only http proxies are supported”

    After browsing through some github issues, I found the notorious issue #845 >>https://github.com/aio-libs/aiohttp/issues/845, which states that https proxies are not supported by aiohttp..

    Do you have a way around this lil’ hurdle?

  4. Hi Ronnie, thank you for the kind words – I’m so glad it’s been helpful. I’m afraid I have absolutely no idea how to make aiohttp work for https proxies – sorry!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.