Created
June 20, 2012 21:12
-
-
Save octplane/2962260 to your computer and use it in GitHub Desktop.
Extend tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SelfableTask(tasks.WrappedCallableTask): | |
def __init__(self, callable, *args, **kwargs): | |
super(SelfableTask, self).__init__(callable, *args, **kwargs) | |
if hasattr(callable, '__module__'): | |
self.__module__ = callable.__module__ | |
def run(self, *args, **kwargs): | |
old_module = env.get('current_module', None) | |
old_task = env.get('current_task', None) | |
env['current_task'] = self.__name__ | |
env['current_module'] = self.__module__ | |
return self.wrapped(*args, **kwargs) | |
if not old_task is None: | |
env['current_task'] = old_task | |
if not old_module is None: | |
env['current_module'] = old_module | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment