From 50528f98b2a5a4f74514c99914a767cf9d0a4a51 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 2 Sep 2017 19:35:26 -0400 Subject: [PATCH] remove decorator decorator Signed-off-by: Kenneth Reitz --- Pipfile | 3 --- background.py | 16 ++++++++-------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Pipfile b/Pipfile index cb9ca45..556f66a 100644 --- a/Pipfile +++ b/Pipfile @@ -1,6 +1,3 @@ [[source]] url = "https://pypi.python.org/simple" verify_ssl = true - -[packages] -decorator = "*" diff --git a/background.py b/background.py index d786da3..05bf6e2 100644 --- a/background.py +++ b/background.py @@ -3,8 +3,6 @@ import multiprocessing import concurrent.futures -from decorator import decorator - def default_n(): return multiprocessing.cpu_count() @@ -23,15 +21,17 @@ def run(f, *args, **kwargs): return f -@decorator + def task(f, *args, **kwargs): - result = run(f, *args, **kwargs) - results.append(result) + def do_task(): + result = run(f, *args, **kwargs) + results.append(result) - for cb in callbacks: - result.add_done_callback(cb) + for cb in callbacks: + result.add_done_callback(cb) - return result + return result + return do_task def callback(f): callbacks.append(f)