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 seconds and freezes up my app. However, when I try to await a call to that module I receive the TypeError:
TypeError: object dict can't be used in 'await' expression
import thirdPartyAPIwrapper async def getData(): retrienveData = await thirdPartyAPIWrapper.data() return await retrieveData def main(): loop = asncio.get_event_loop() data = loop.run_until_complete(getData()) loop.close return data
Why can I not await a type(‘dict’)? Is there a way around this?
If async/await with asyncio will not work with a third party module that doesn’t return a coroutine then what are my other options?