Trying ro fix multi-threading issue

This commit is contained in:
2022-09-04 17:38:45 +02:00
parent 03a6d9b54f
commit 27b05b6184
7 changed files with 111 additions and 28 deletions

View File

@@ -1,4 +1,5 @@
import os
import sys
from urllib import request
from urllib.error import HTTPError, URLError
from bs4 import BeautifulSoup, Tag, ResultSet
@@ -138,6 +139,7 @@ class WebPicDownloader():
Stop the downloading and processing of images (method for use in a thread).
"""
self.thread_run = False
sys.exit(0)
def download(self, url: str, folder_name: str) -> bool:
"""
@@ -158,8 +160,10 @@ class WebPicDownloader():
self.messenger(f"WebPicDownloader found {len(images)} images on the website.")
for i, img in enumerate(images):
print("check")
print(id(self))
if not self.thread_run:
exit()
print("return")
try:
self.messenger(f"Start downloading image {i}.")
img_link = self.__find_img_link(img)