mtest: clean up asyncio event loop instantiation

Fix a TODO comment about moving to asyncio.run, now that we use
sufficiently new python to do it.

Note that we create an event loop for Windows using the new python
defaults, but in a completely different part of the code from where we
need to use it. Since asyncio.run creates the loop on its own, we need
to set the default policy instead -- which we probably should have done
all along.
pull/11215/head
Eli Schwartz 2 years ago
parent 56312c0579
commit ab8081fab6
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 13
      mesonbuild/mtest.py

@ -1925,9 +1925,12 @@ class TestHarness:
def run_tests(self, runners: T.List[SingleTestRunner]) -> None:
try:
self.open_logfiles()
# Replace with asyncio.run once we can require Python 3.7
loop = asyncio.get_event_loop()
loop.run_until_complete(self._run_tests(runners))
# TODO: this is the default for python 3.8
if sys.platform == 'win32':
asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy())
asyncio.run(self._run_tests(runners))
finally:
self.close_logfiles()
@ -2090,10 +2093,6 @@ def run(options: argparse.Namespace) -> int:
if options.wrapper:
check_bin = options.wrapper[0]
if sys.platform == 'win32':
loop = asyncio.ProactorEventLoop()
asyncio.set_event_loop(loop)
if check_bin is not None:
exe = ExternalProgram(check_bin, silent=True)
if not exe.found():

Loading…
Cancel
Save