8000 Improved documentation in Application. · cool-RR/python-prompt-toolkit@3dfc48b · GitHub
[go: up one dir, main page]

Skip to content

Commit 3dfc48b

Browse files
Improved documentation in Application.
1 parent 03def05 commit 3dfc48b

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

prompt_toolkit/application/application.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,9 @@ class Application(Generic[_AppResult]):
179179
180180
app = Application(...)
181181
app.run()
182+
183+
# Or
184+
await app.run_async()
182185
"""
183186
def __init__(self,
184187
layout: Optional[Layout] = None,
@@ -570,23 +573,10 @@ def _pre_run(self, pre_run: Optional[Callable[[], None]] = None) -> None:
570573

571574
async def run_async(self, pre_run: Optional[Callable[[], None]] = None) -> _AppResult:
572575
"""
573-
Run asynchronous. Return a prompt_toolkit
574-
:class:`~prompt_toolkit.eventloop.Future` object.
575-
576-
If you wish to run on top of asyncio, remember that a prompt_toolkit
577-
`Future` needs to be converted to an asyncio `Future`. The cleanest way
578-
is to call :meth:`~prompt_toolkit.eventloop.Future.to_asyncio_future`.
579-
Also make sure to tell prompt_toolkit to use the asyncio event loop.
580-
581-
.. code:: python
582-
583-
from prompt_toolkit.eventloop import use_asyncio_event_loop
584-
from asyncio import get_event_loop
585-
586-
use_asyncio_event_loop()
587-
get_event_loop().run_until_complete(
588-
application.run_async().to_asyncio_future())
589-
576+
Run the prompt_toolkit :class:`~prompt_toolkit.application.Application`
577+
until :meth:`~prompt_toolkit.application.Application.exit` has been
578+
called. Return the value that was passed to
579+
:meth:`~prompt_toolkit.application.Application.exit`.
590580
"""
591581
assert not self._is_running, 'Application is already running.'
592582

0 commit comments

Comments
 (0)
0