Skip to content

Instantly share code, notes, and snippets.

@octplane
Created June 20, 2012 21:12
Show Gist options
  • Save octplane/2962260 to your computer and use it in GitHub Desktop.
Save octplane/2962260 to your computer and use it in GitHub Desktop.
Extend tasks
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