diff options
author | brian.quinlan <devnull@localhost> | 2009-05-28 11:37:35 +0000 |
---|---|---|
committer | brian.quinlan <devnull@localhost> | 2009-05-28 11:37:35 +0000 |
commit | e0d3a5e70fbb45839c954a56968f5b3b661208b0 (patch) | |
tree | ef82f7938aa3c2d25442a9ec0cbf142b1b52714d | |
parent | b4849a1e72600c2d45eae9bb3fcf764feba48d9f (diff) | |
download | futures-e0d3a5e70fbb45839c954a56968f5b3b661208b0.tar.gz |
Provide a replacement for functools.partial for python 2.4
-rw-r--r-- | python2/futures/_base.py | 16 |
1 files 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): |