textual icon indicating copy to clipboard operation
textual copied to clipboard

Devtools slowness

Open darrenburns opened this issue 3 years ago • 1 comments

When running on my personal laptop, devtools slows a Textual application down drastically. When I close the devtools, I get the following error (which I have never seen on the M1 machines).

I don't know if the slowness and the error below are related in any way, but they both only occur on non-M1 machines it appears.

^Cunhandled exception during asyncio.run() shutdown
task: <Task finished name='Task-1' coro=<_run_app() done, defined at /Users/darrenburns/Library/Caches/pypoetry/virtualenvs/textual-oLD0X8_j-py3.9/lib/python3.9/site-packages/aiohttp/web.py:287> exception=RuntimeError("Task <Task pending name='Task-4' coro=<Event.wait() running at /usr/local/Cellar/[email protected]/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/locks.py:226> cb=[_release_waiter(<Future pendi...10c667280>()]>)() at /usr/local/Cellar/[email protected]/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/tasks.py:416]> got Future <Future pending> attached to a different loop")>
Traceback (most recent call last):
  File "/Users/darrenburns/Library/Caches/pypoetry/virtualenvs/textual-oLD0X8_j-py3.9/lib/python3.9/site-packages/aiohttp/web.py", line 431, in _run_app
    await asyncio.sleep(delay)
  File "/usr/local/Cellar/[email protected]/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/tasks.py", line 652, in sleep
    return await future
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/darrenburns/Library/Caches/pypoetry/virtualenvs/textual-oLD0X8_j-py3.9/lib/python3.9/site-packages/aiohttp/web.py", line 433, in _run_app
    await runner.cleanup()
  File "/Users/darrenburns/Library/Caches/pypoetry/virtualenvs/textual-oLD0X8_j-py3.9/lib/python3.9/site-packages/aiohttp/web_runner.py", line 293, in cleanup
    await site.stop()
  File "/Users/darrenburns/Library/Caches/pypoetry/virtualenvs/textual-oLD0X8_j-py3.9/lib/python3.9/site-packages/aiohttp/web_runner.py", line 76, in stop
    await self._runner.shutdown()
  File "/Users/darrenburns/Library/Caches/pypoetry/virtualenvs/textual-oLD0X8_j-py3.9/lib/python3.9/site-packages/aiohttp/web_runner.py", line 369, in shutdown
    await self._app.shutdown()
  File "/Users/darrenburns/Library/Caches/pypoetry/virtualenvs/textual-oLD0X8_j-py3.9/lib/python3.9/site-packages/aiohttp/web_app.py", line 424, in shutdown
    await self.on_shutdown.send(self)
  File "/Users/darrenburns/Library/Caches/pypoetry/virtualenvs/textual-oLD0X8_j-py3.9/lib/python3.9/site-packages/aiosignal/__init__.py", line 36, in send
    await receiver(*args, **kwargs)  # type: ignore
  File "/Users/darrenburns/Code/textual/src/textual/devtools/server.py", line 31, in _on_shutdown
    await service.shutdown()
  File "/Users/darrenburns/Code/textual/src/textual/devtools/service.py", line 111, in shutdown
    await self.size_poll_task
  File "/Users/darrenburns/Code/textual/src/textual/devtools/service.py", line 70, in _console_size_poller
    await asyncio.wait_for(
  File "/usr/local/Cellar/[email protected]/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/tasks.py", line 479, in wait_for
    return fut.result()
  File "/usr/local/Cellar/[email protected]/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/locks.py", line 226, in wait
    await fut
RuntimeError: Task <Task pending name='Task-4' coro=<Event.wait() running at /usr/local/Cellar/[email protected]/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/locks.py:226> cb=[_release_waiter(<Future pendi...10c667280>()]>)() at /usr/local/Cellar/[email protected]/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/tasks.py:416]> got Future <Future pending> attached to a different loop

darrenburns avatar Jun 10 '22 10:06 darrenburns

I wonder if it could "just" be related to the Python version?

While working on making the App class work again on Python<3.10 I ended up having to do this - as asyncio.get_event_loop() is deprecated since Python 3.10, but seem to still be the way to go for older versions: https://github.com/Textualize/textual/blob/css/src/textual/app.py#L518-L524

(with _ASYNCIO_GET_EVENT_LOOP_IS_DEPRECATED = sys.version_info >= (3, 10, 0) at the start of the app module)

olivierphi avatar Jun 16 '22 10:06 olivierphi

https://github.com/Textualize/textual/wiki/Sorry-we-closed-your-issue

willmcgugan avatar Oct 25 '22 09:10 willmcgugan

Did we solve your problem?

Glad we could help!

github-actions[bot] avatar Oct 25 '22 09:10 github-actions[bot]