Closed shmilylty closed 4 years ago
Add asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
in top of file
couse python3.8 add Proactor loop in asyncio and broke compatability
Add
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
in top of file couse python3.8 add Proactor loop in asyncio and broke compatability
But I want to use proactor loop,have any idea plz?
So add it explicitly
import aiodns
import asyncio
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
async def query_a(name):
resolver = aiodns.DNSResolver()
return await resolver.query(name, "A")
if __name__ == '__main__':
res = asyncio.run(query_a('qq.com'))
So add it explicitly
import aiodns import asyncio asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) async def query_a(name): resolver = aiodns.DNSResolver() return await resolver.query(name, "A") if __name__ == '__main__': res = asyncio.run(query_a('qq.com'))
I mean,use ProactorEventLoop,not use SelectorEventLoop.
https://docs.python.org/3.8/library/asyncio-platforms.html#asyncio-platform-support
ProactorEventLoop has the following limitations:
The loop.add_reader() and loop.add_writer() methods are not supported.
We depend on the add_reader / add_writer APIs for integrating with c-ares.
Env
Win10 19.09 x64 Python 3.8.0
Code
Error