diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2022-12-25 01:45:01 -0500 |
---|---|---|
committer | Eli Schwartz <eschwartz@archlinux.org> | 2023-01-04 16:46:51 -0500 |
commit | ab8081fab66eafcb35021f45ffae0648b658733e (patch) | |
tree | d67ddb9268535aae672a33afb6ceb03195fa3821 /mesonbuild/mtest.py | |
parent | 56312c057938237671524f49c5206e2a98be7863 (diff) | |
download | meson-ab8081fab66eafcb35021f45ffae0648b658733e.zip meson-ab8081fab66eafcb35021f45ffae0648b658733e.tar.gz meson-ab8081fab66eafcb35021f45ffae0648b658733e.tar.bz2 |
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.
Diffstat (limited to 'mesonbuild/mtest.py')
-rw-r--r-- | mesonbuild/mtest.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py index b398705..5c584e0 100644 --- a/mesonbuild/mtest.py +++ b/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(): |