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.
pull/11215/head
Eli Schwartz 2 years ago
parent 9aff189e31
commit 56312c0579
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 5
      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)

Loading…
Cancel
Save