Added manga-py source

This commit is contained in:
2019-12-14 22:33:14 -05:00
parent 9a4dd4b09b
commit 45067caea6
420 changed files with 18054 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
from threading import Thread
class MultiThreads:
threads = None
max_threads = 2
to_run = None
def __init__(self):
self.threads = []
self.to_run = []
try:
import multiprocessing
self.max_threads = multiprocessing.cpu_count()
except Exception:
pass
def add(self, target: callable, args: tuple):
self.threads.append(Thread(target=target, args=args))
def _run_processes(self, callback: callable = None, n: int = None):
for t in self.to_run:
if not n:
t.join()
callback is not None and callback()
def start(self, callback: callable = None):
for n, t in enumerate(self.threads): # starting all threads
t.start()
self.to_run.append(t)
self._run_processes(callback, (n + 1) % self.max_threads)
self._run_processes(callback)
self.threads = []