From 84f1ffcd95886dc65375988c4ca6105edaddcf2f Mon Sep 17 00:00:00 2001 From: itdominator <1itdominator@gmail.com> Date: Fri, 22 May 2026 20:26:14 -0500 Subject: [PATCH] Improved startup time due to request library slowing it down; fixed download throwing errors due to weird thread setup --- src/core/widgets/ocr_window.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/core/widgets/ocr_window.py b/src/core/widgets/ocr_window.py index d5c04be..bc142dc 100644 --- a/src/core/widgets/ocr_window.py +++ b/src/core/widgets/ocr_window.py @@ -1,6 +1,5 @@ # Python imports import os -import requests import subprocess # Lib imports @@ -92,7 +91,7 @@ class OCRWindow(Gtk.Window): spinner = Gtk.Spinner.new() parent.add(spinner) - GLib.idle_add(self.__download_file, self.download_url, spinner) + self.__download_file(self.download_url, spinner) @daemon_threaded def __download_file(self, url = None, spinner = None): @@ -100,11 +99,13 @@ class OCRWindow(Gtk.Window): if not spinner: return if not url == self.download_url: return - spinner.show() spinner.start() + spinner.show() + import requests + session = requests.Session() # NOTE the stream = True parameter below - with requests.get(url, stream = True) as r: + with session.get(url, stream = True, timeout = 30) as r: r.raise_for_status() with open(self.tesseract_path, 'wb') as f: