From 8af532f25ece2c01d81e6859225b7209f2f64321 Mon Sep 17 00:00:00 2001 From: Andrew Wong Date: Wed, 30 Sep 2020 19:22:31 +1000 Subject: [PATCH] Remove unreachable shutdown code * Implementing `__del__` is discouraged * Imports (i.e. `import logging`) are cleaned up, leading to NoneType related errors * When running via GUI mode, the shutdown code is never reached; we can let Python's internal GC clean everything --- trimage/ThreadPool/ThreadPool.py | 7 ------- trimage/trimage.py | 3 --- 2 files changed, 10 deletions(-) diff --git a/trimage/ThreadPool/ThreadPool.py b/trimage/ThreadPool/ThreadPool.py index 9f9e051..17e55e4 100644 --- a/trimage/ThreadPool/ThreadPool.py +++ b/trimage/ThreadPool/ThreadPool.py @@ -30,9 +30,6 @@ class ThreadPoolMixIn: def __init__(self, threadpool=None): if (threadpool == None): threadpool = ThreadPool() - self.__private_threadpool = True - else: - self.__private_threadpool = False self.__threadpool = threadpool @@ -52,10 +49,6 @@ class ThreadPoolMixIn: def process_request(self, request, client_address): self.__threadpool.add_job(self.process_request_thread, [request, client_address]) - def shutdown(self): - if (self.__private_threadpool): self.__threadpool.shutdown() - - class AddJobException(Exception): ''' Exceptoion raised when a Job could not be added diff --git a/trimage/trimage.py b/trimage/trimage.py index 3f7dbc3..1ef81be 100644 --- a/trimage/trimage.py +++ b/trimage/trimage.py @@ -409,9 +409,6 @@ class Worker(QThread): self.toDisplay = Queue() self.threadpool = ThreadPool(max_workers=cpu_count()) - def __del__(self): - self.threadpool.shutdown() - def compress_file(self, images, showapp, verbose, imagelist): """Start the worker thread.""" for image in images: