aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts
diff options
context:
space:
mode:
authorarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-04-06 18:18:01 +0300
committerarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-04-06 18:18:01 +0300
commit01fbacb386809436dfa331780875aed72cb76118 (patch)
tree04c911ad96ff0523bd4d3e7a45c23cf2f2d7607d /contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts
parent48fb997d7f820a474b9094a72d9798a95ec612b7 (diff)
downloadydb-01fbacb386809436dfa331780875aed72cb76118.tar.gz
intermediate changes
ref:b4f892f3c2b06a356c155f73c27efc5661a7fb89
Diffstat (limited to 'contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts')
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/prompt.py14
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/utils.py11
2 files changed, 15 insertions, 10 deletions
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/prompt.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/prompt.py
index a8d8a58555..4dc1b18d1c 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/prompt.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/prompt.py
@@ -900,6 +900,7 @@ class PromptSession(Generic[_T]):
accept_default: bool = False,
pre_run: Optional[Callable[[], None]] = None,
set_exception_handler: bool = True,
+ handle_sigint: bool = True,
in_thread: bool = False,
) -> _T:
"""
@@ -1028,10 +1029,12 @@ class PromptSession(Generic[_T]):
# dumb prompt.
if self._output is None and is_dumb_terminal():
with self._dumb_prompt(self.message) as dump_app:
- return dump_app.run(in_thread=in_thread)
+ return dump_app.run(in_thread=in_thread, handle_sigint=handle_sigint)
return self.app.run(
- set_exception_handler=set_exception_handler, in_thread=in_thread
+ set_exception_handler=set_exception_handler,
+ in_thread=in_thread,
+ handle_sigint=handle_sigint,
)
@contextmanager
@@ -1132,6 +1135,7 @@ class PromptSession(Generic[_T]):
accept_default: bool = False,
pre_run: Optional[Callable[[], None]] = None,
set_exception_handler: bool = True,
+ handle_sigint: bool = True,
) -> _T:
if message is not None:
@@ -1219,9 +1223,11 @@ class PromptSession(Generic[_T]):
# dumb prompt.
if self._output is None and is_dumb_terminal():
with self._dumb_prompt(self.message) as dump_app:
- return await dump_app.run_async()
+ return await dump_app.run_async(handle_sigint=handle_sigint)
- return await self.app.run_async(set_exception_handler=set_exception_handler)
+ return await self.app.run_async(
+ set_exception_handler=set_exception_handler, handle_sigint=handle_sigint
+ )
def _add_pre_run_callables(
self, pre_run: Optional[Callable[[], None]], accept_default: bool
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/utils.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/utils.py
index c7ce74e627..a628f4b6ae 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/utils.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/utils.py
@@ -183,20 +183,19 @@ def print_container(
else:
output = get_app_session().output
- def exit_immediately() -> None:
- # Use `call_from_executor` to exit "soon", so that we still render one
- # initial time, before exiting the application.
- get_event_loop().call_soon(lambda: app.exit())
-
app: Application[None] = Application(
layout=Layout(container=container),
output=output,
+ # `DummyInput` will cause the application to terminate immediately.
input=DummyInput(),
style=_create_merged_style(
style, include_default_pygments_style=include_default_pygments_style
),
)
- app.run(pre_run=exit_immediately, in_thread=True)
+ try:
+ app.run(in_thread=True)
+ except EOFError:
+ pass
def _create_merged_style(