Improved startup time due to request library slowing it down; fixed download throwing errors due to weird thread setup
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user