Skip to content

Commit 3303c87

Browse files
Accept 'handle_sigint' parameter in PromptSession.
1 parent f1aefcc commit 3303c87

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

prompt_toolkit/shortcuts/prompt.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,7 @@ def prompt(
900900
accept_default: bool = False,
901901
pre_run: Optional[Callable[[], None]] = None,
902902
set_exception_handler: bool = True,
903+
handle_sigint: bool = True,
903904
in_thread: bool = False,
904905
) -> _T:
905906
"""
@@ -1028,10 +1029,12 @@ class itself. For these, passing in ``None`` will keep the current
10281029
# dumb prompt.
10291030
if self._output is None and is_dumb_terminal():
10301031
with self._dumb_prompt(self.message) as dump_app:
1031-
return dump_app.run(in_thread=in_thread)
1032+
return dump_app.run(in_thread=in_thread, handle_sigint=handle_sigint)
10321033

10331034
return self.app.run(
1034-
set_exception_handler=set_exception_handler, in_thread=in_thread
1035+
set_exception_handler=set_exception_handler,
1036+
in_thread=in_thread,
1037+
handle_sigint=handle_sigint,
10351038
)
10361039

10371040
@contextmanager
@@ -1132,6 +1135,7 @@ async def prompt_async(
11321135
accept_default: bool = False,
11331136
pre_run: Optional[Callable[[], None]] = None,
11341137
set_exception_handler: bool = True,
1138+
handle_sigint: bool = True,
11351139
) -> _T:
11361140

11371141
if message is not None:
@@ -1219,9 +1223,11 @@ async def prompt_async(
12191223
# dumb prompt.
12201224
if self._output is None and is_dumb_terminal():
12211225
with self._dumb_prompt(self.message) as dump_app:
1222-
return await dump_app.run_async()
1226+
return await dump_app.run_async(handle_sigint=handle_sigint)
12231227

1224-
return await self.app.run_async(set_exception_handler=set_exception_handler)
1228+
return await self.app.run_async(
1229+
set_exception_handler=set_exception_handler, handle_sigint=handle_sigint
1230+
)
12251231

12261232
def _add_pre_run_callables(
12271233
self, pre_run: Optional[Callable[[], None]], accept_default: bool

0 commit comments

Comments
 (0)