Skip to content

Commit

Permalink
Fix issues with termination of progress bars.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanslenders committed Feb 14, 2023
1 parent 71d1957 commit 5a1484b
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/prompt_toolkit/shortcuts/progress_bar/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import signal
import threading
import traceback
from asyncio import new_event_loop, set_event_loop
from typing import (
Callable,
Generic,
Expand Down Expand Up @@ -156,7 +155,6 @@ def keyboard_interrupt_to_main_thread() -> None:

self._thread: threading.Thread | None = None

self._app_loop = new_event_loop()
self._has_sigwinch = False
self._app_started = threading.Event()

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

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

# Quit UI application.
if self.app.is_running:
self._app_loop.call_soon_threadsafe(self.app.exit)
if self.app.is_running and self.app.loop is not None:
self.app.loop.call_soon_threadsafe(self.app.exit)

if self._thread is not None:
self._thread.join()
self._app_loop.close()

def __call__(
self,
Expand Down

0 comments on commit 5a1484b

Please sign in to comment.