From 56312c057938237671524f49c5206e2a98be7863 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Sun, 1 Jan 2023 17:37:01 -0500 Subject: mtest: delay creation of asyncio lock until event loop exists In https://bugs.python.org/issue42392 this stopped implicitly creating an event loop if none exists. We created it before running _run_tests(), so it would auto-create an event loop and set the default, which means we cannot create one explicitly on our own schedule or we end up with two of them. Delay this until we actually start the logger. This happens inside the actual testsuite loop, so it finds the running loop and doesn't create a new one, even on python <3.10. --- mesonbuild/mtest.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'mesonbuild') diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py index bcf84d3..b398705 100644 --- a/mesonbuild/mtest.py +++ b/mesonbuild/mtest.py @@ -502,7 +502,9 @@ class ConsoleLogger(TestLogger): self.progress_task = None # type: T.Optional[asyncio.Future] self.max_left_width = 0 # type: int self.stop = False - self.update = asyncio.Event() + # TODO: before 3.10 this cannot be created immediately, because + # it will create a new event loop + self.update: asyncio.Event self.should_erase_line = '' self.test_count = 0 self.started_tests = 0 @@ -600,6 +602,7 @@ class ConsoleLogger(TestLogger): self.emit_progress(harness) self.flush() + self.update = asyncio.Event() self.test_count = harness.test_count self.cols = max(self.cols, harness.max_left_width + 30) -- cgit v1.1