From 41c14b82c41de817c0b4ab7a4e721f32cb71ac54 Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Tue, 10 Aug 2010 14:00:18 -0700 Subject: [PATCH] Remove the ability to pre-bind parameters in stack_context.wrap. This functionality was incorrect and unused, and unlike async_callback, I don't think the implicit binding is a good fit for this API. --- tornado/stack_context.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/tornado/stack_context.py b/tornado/stack_context.py index 1946a5800..8905ca62b 100644 --- a/tornado/stack_context.py +++ b/tornado/stack_context.py @@ -93,16 +93,13 @@ def NullContext(): finally: _state.contexts = old_contexts -def wrap(fn, *args, **kwargs): +def wrap(fn): '''Returns a callable object that will resore the current StackContext when executed. Use this whenever saving a callback to be executed later in a different execution context (either in a different thread or asynchronously in the same thread). - - As a convenience, also binds parameters to the given function - like functools.partial. ''' # functools.wraps doesn't appear to work on functools.partial objects #@functools.wraps(fn) @@ -131,11 +128,7 @@ def wrap(fn, *args, **kwargs): callback(*args, **kwargs) if getattr(fn, 'stack_context_wrapped', False): return fn - if args or kwargs: - callback = functools.partial(fn, *args, **kwargs) - else: - callback = fn contexts = _state.contexts - result = functools.partial(wrapped, callback, contexts, *args, **kwargs) + result = functools.partial(wrapped, fn, contexts) result.stack_context_wrapped = True return result -- 2.47.2