python-asyncio TypeError: object dict can't be used in 'await' expression

后端 未结 3 1692
谎友^
谎友^ 2020-12-29 04:44

I am using a third party module to retrieve data from an API. I simply would like to asynchronously await the module to return the data which occasionally takes several seco

3条回答
  •  死守一世寂寞
    2020-12-29 05:33

    I am writing test cases and I need to mock async functionality. So, you can write a simple helper function like so.

    async def resolve(val):
        return val
    

    Now you can await anything

    foo = resolve(1) 
    await foo # No error!
    

提交回复
热议问题