From e817472ccdabe571bfb4b51661774695f6c2fb5c Mon Sep 17 00:00:00 2001 From: buthed010203 Date: Sat, 20 May 2023 12:00:38 -0400 Subject: [PATCH] Potential fix for windows crashing on RemoveOrphaned --- modules/core/remove_orphaned.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/core/remove_orphaned.py b/modules/core/remove_orphaned.py index 030ee3b..202bec6 100644 --- a/modules/core/remove_orphaned.py +++ b/modules/core/remove_orphaned.py @@ -7,7 +7,6 @@ from multiprocessing import Pool from modules import util logger = util.logger -_config = None class RemoveOrphaned: @@ -23,7 +22,7 @@ class RemoveOrphaned: global _config _config = self.config - self.pool = Pool(processes=max(cpu_count() - 1, 1)) + self.pool = Pool(processes=max(cpu_count() - 1, 1), initializer=init_pool, initargs=(self.config,)) self.rem_orphaned() self.cleanup_pool() @@ -106,6 +105,10 @@ class RemoveOrphaned: self.pool.join() +def init_pool(conf): + global _config + _config = conf + def get_full_path_of_torrent_files(torrent_files, save_path): fullpath_torrent_files = [] for file in torrent_files: @@ -115,7 +118,6 @@ def get_full_path_of_torrent_files(torrent_files, save_path): fullpath_torrent_files.append(fullpath) return fullpath_torrent_files - def move_orphan(file): src = file.replace(_config.root_dir, _config.remote_dir) # Could be optimized to only run when root != remote dest = os.path.join(_config.orphaned_dir, file.replace(_config.root_dir, ""))