Skip to content

Commit 5a1484b

Browse files
Fix issues with termination of progress bars.
1 parent 71d1957 commit 5a1484b

File tree

1 file changed

+2
-6
lines changed
  • src/prompt_toolkit/shortcuts/progress_bar

1 file changed

+2
-6
lines changed

src/prompt_toolkit/shortcuts/progress_bar/base.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import signal
1717
import threading
1818
import traceback
19-
from asyncio import new_event_loop, set_event_loop
2019
from typing import (
2120
Callable,
2221
Generic,
@@ -156,7 +155,6 @@ def keyboard_interrupt_to_main_thread() -> None:
156155

157156
self._thread: threading.Thread | None = None
158157

159-
self._app_loop = new_event_loop()
160158
self._has_sigwinch = False
161159
self._app_started = threading.Event()
162160

@@ -224,7 +222,6 @@ def width_for_formatter(formatter: Formatter) -> AnyDimension:
224222

225223
# Run application in different thread.
226224
def run() -> None:
227-
set_event_loop(self._app_loop)
228225
try:
229226
self.app.run(pre_run=self._app_started.set)
230227
except BaseException as e:
@@ -245,12 +242,11 @@ def __exit__(self, *a: object) -> None:
245242
self._app_started.wait()
246243

247244
# Quit UI application.
248-
if self.app.is_running:
249-
self._app_loop.call_soon_threadsafe(self.app.exit)
245+
if self.app.is_running and self.app.loop is not None:
246+
self.app.loop.call_soon_threadsafe(self.app.exit)
250247

251248
if self._thread is not None:
252249
self._thread.join()
253-
self._app_loop.close()
254250

255251
def __call__(
256252
self,

0 commit comments

Comments
 (0)