From 46eafd4f1bbed3949523e769d3edf6f5fb04fb14 Mon Sep 17 00:00:00 2001 From: tech234a <46801700+tech234a@users.noreply.github.com> Date: Mon, 21 Sep 2020 01:00:21 -0400 Subject: [PATCH] Add threading to export.py CLI (speed improvement) --- export.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/export.py b/export.py index ef8f0aa..b9b7f4e 100644 --- a/export.py +++ b/export.py @@ -161,6 +161,7 @@ if __name__ == "__main__": del cookies from sys import argv from queue import Queue + from threading import Thread langs = ['ab', 'aa', 'af', 'sq', 'ase', 'am', 'ar', 'arc', 'hy', 'as', 'ay', 'az', 'bn', 'ba', 'eu', 'be', 'bh', 'bi', 'bs', 'br', 'bg', 'yue', 'yue-HK', 'ca', 'chr', 'zh-CN', 'zh-HK', 'zh-Hans', 'zh-SG', 'zh-TW', 'zh-Hant', 'cho', 'co', 'hr', 'cs', 'da', 'nl', 'nl-BE', 'nl-NL', 'dz', 'en', 'en-CA', 'en-IN', 'en-IE', 'en-GB', 'en-US', 'eo', 'et', 'fo', 'fj', 'fil', 'fi', 'fr', 'fr-BE', @@ -189,4 +190,15 @@ if __name__ == "__main__": for lang in langs: jobs.put((lang, video)) - subprrun(jobs, mysession) \ No newline at end of file + subthreads = [] + + for r in range(50): + subrunthread = Thread(target=subprrun, args=(jobs,mysession)) + subrunthread.start() + subthreads.append(subrunthread) + del subrunthread + + for xa in subthreads: + xa.join() #bug (occurred once: the script ended before the last thread finished) + subthreads.remove(xa) + del xa \ No newline at end of file