Skip to content

Commit f74bf64

Browse files
committed
improve download
1 parent e2a2262 commit f74bf64

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

oclp_r/support/network_handler.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -534,10 +534,9 @@ def stop(self) -> None:
534534
"""
535535
Stop the download
536536
537-
If the download is active, this function will hold the thread until stopped
537+
If the download is active, this function will hold the thread until stopped or timeout
538538
"""
539539

540540
self.should_stop = True
541-
if self.active_thread:
542-
while self.active_thread.is_alive():
543-
time.sleep(1)
541+
if self.active_thread and self.active_thread.is_alive():
542+
self.active_thread.join(timeout=10)

oclp_r/wx_gui/gui_download.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,14 @@ def terminate_download(self) -> None:
103103
if wx.MessageBox("Are you sure you want to cancel the download?", "Cancel Download", wx.YES_NO | wx.ICON_QUESTION | wx.NO_DEFAULT) == wx.YES:
104104
logging.info("User cancelled download")
105105
self.user_cancelled = True
106-
self.download_obj.stop()
106+
# Show a status message while stopping the download
107+
status_dialog = wx.MessageDialog(self.frame_modal, "Cancelling download, please wait...", "Cancelling", wx.CANCEL | wx.STAY_ON_TOP)
108+
status_dialog.Show()
109+
wx.Yield()
110+
111+
try:
112+
self.download_obj.stop()
113+
finally:
114+
status_dialog.Destroy()
107115

108116

0 commit comments

Comments
 (0)