tests.generate: stop using asyncio.get_event_loop (#349)
The use of `asyncio.get_event_loop()` has been deprecated in python 3.10+. We replace this usage with `asyncio.run()` for python 3.7+.
This commit is contained in:
parent
a836fb23bc
commit
9c1bf25304
@ -159,8 +159,18 @@ def main():
|
|||||||
whitelist = set(sys.argv[1:])
|
whitelist = set(sys.argv[1:])
|
||||||
|
|
||||||
if platform.system() == "Windows":
|
if platform.system() == "Windows":
|
||||||
asyncio.set_event_loop(asyncio.ProactorEventLoop())
|
# for python version prior to 3.8, loop policy needs to be set explicitly
|
||||||
|
# https://docs.python.org/3/library/asyncio-policy.html#asyncio.DefaultEventLoopPolicy
|
||||||
|
try:
|
||||||
|
asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy())
|
||||||
|
except AttributeError:
|
||||||
|
# python < 3.7 does not have asyncio.WindowsProactorEventLoopPolicy
|
||||||
|
asyncio.get_event_loop_policy().set_event_loop(asyncio.ProactorEventLoop())
|
||||||
|
|
||||||
|
try:
|
||||||
|
asyncio.run(generate(whitelist, verbose))
|
||||||
|
except AttributeError:
|
||||||
|
# compatibility code for python < 3.7
|
||||||
asyncio.get_event_loop().run_until_complete(generate(whitelist, verbose))
|
asyncio.get_event_loop().run_until_complete(generate(whitelist, verbose))
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user