From dfed1d5cfb13e9b99f1cd3b8b0836f794f2f7beb Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 2 Sep 2017 19:36:30 -0400 Subject: [PATCH] cleanup Signed-off-by: Kenneth Reitz --- background.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/background.py b/background.py index 05bf6e2..d6140d2 100644 --- a/background.py +++ b/background.py @@ -3,6 +3,7 @@ import multiprocessing import concurrent.futures + def default_n(): return multiprocessing.cpu_count() @@ -11,6 +12,7 @@ pool = concurrent.futures.ThreadPoolExecutor(max_workers=n) callbacks = [] results = [] + def run(f, *args, **kwargs): pool._max_workers = n @@ -33,8 +35,11 @@ def task(f, *args, **kwargs): return result return do_task + def callback(f): callbacks.append(f) + def register_callback(): f() + return register_callback