textual icon indicating copy to clipboard operation
textual copied to clipboard

Create new event loop as fallback behaviour.

Open paul-ollis opened this issue 7 months ago • 1 comments

The method App.push_screen tries to create a Future using asyncio.get_running_loop(). If this raises a RuntimeError it simply invokes Future(), as a fallback, order to support some of the tests.

When running tests using pytest-xdist it is possible for this fallback mechanism to fail and instead raise another RuntimeError when Future() tries to get the 'standard' event loop. This is a rare occurrence with the current tests' structure, but I have seen it a number of times.

It is causes by a test that invokes App.run (which invokes asyncio.run) being executed before a test that depends on the aforementioned fallback mechanism. Both tests must be executed by the same pytest-xdist worker process.

Please review the following checklist.

  • [n/a ] Docstrings on all new or modified functions / classes
  • [n/a ] Updated documentation
  • [n/a ] Updated CHANGELOG.md (where appropriate)

paul-ollis avatar Apr 20 '25 17:04 paul-ollis

This is resolved by https://github.com/Textualize/textual/pull/5765

graingert avatar Jun 01 '25 16:06 graingert

I have converted this to a draft on the assumption that by #5765 will get merged in due course.

paul-ollis avatar Jun 16 '25 19:06 paul-ollis