(coro)
| 99 | |
| 100 | |
| 101 | def async_run(coro): |
| 102 | # This technique shamelessly cribbed from Textual itself... |
| 103 | # `asyncio.get_event_loop()` is deprecated since Python 3.10: |
| 104 | asyncio_get_event_loop_is_deprecated = sys.version_info >= (3, 10, 0) |
| 105 | |
| 106 | if asyncio_get_event_loop_is_deprecated: |
| 107 | # N.B. This doesn't work with Python<3.10, as we end up with 2 event loops: |
| 108 | return asyncio.run(coro) |
| 109 | else: |
| 110 | # pragma: no cover |
| 111 | # However, this works with Python<3.10: |
| 112 | event_loop = asyncio.get_event_loop() |
| 113 | return event_loop.run_until_complete(coro) |
searching dependent graphs…