From e0d3a5e70fbb45839c954a56968f5b3b661208b0 Mon Sep 17 00:00:00 2001 From: "brian.quinlan" Date: Thu, 28 May 2009 11:37:35 +0000 Subject: Provide a replacement for functools.partial for python 2.4 --- python2/futures/_base.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/python2/futures/_base.py b/python2/futures/_base.py index 5ad4229..daa4049 100644 --- a/python2/futures/_base.py +++ b/python2/futures/_base.py @@ -1,8 +1,20 @@ -import functools import logging import threading import time +try: + from functools import partial +except ImportError: + def partial(func, *args, **keywords): + def newfunc(*fargs, **fkeywords): + newkeywords = keywords.copy() + newkeywords.update(fkeywords) + return func(*(args + fargs), **newkeywords) + newfunc.func = func + newfunc.args = args + newfunc.keywords = keywords + return newfunc + # The "any" and "all" builtins weren't introduced until Python 2.5. try: any @@ -528,7 +540,7 @@ class Executor(object): Exception: If fn(*args) raises for any values. """ timeout = kwargs.get('timeout') or None - calls = [functools.partial(func, *args) for args in zip(*iterables)] + calls = [partial(func, *args) for args in zip(*iterables)] return self.run_to_results(calls, timeout=timeout) def shutdown(self): -- cgit v1.2.1