Created
January 30, 2014 15:01
-
-
Save avnik/8710313 to your computer and use it in GitHub Desktop.
This file contains 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
# NOTE: overriding __call__ in BaseTask not work, so monkey path Task | |
def deduplicator(f): | |
@wraps(f) | |
def wrapper(self, *a, **kw): | |
if config.get('REDIS_DEDUPLICATION', None): | |
if redis_dedup(self.request.id, self.request.retries): | |
raise Ignore() | |
return f(self, *a, **kw) | |
return wrapper | |
# Not works ;( | |
Task.__call__ = deduplicator(Task.__call__) | |
# This method also not work | |
class MyTask(Task): | |
def __call__(self, *a, **kw): | |
return super(MyTask, self).__call__(*a, **kw) | |
# Following also not work | |
# return Task.__call__(self, *a, **kw) | |
# even following code not works: | |
@task(base=MyTask, ack_late=True) | |
@deduplicator | |
def do_work(arg1, kwarg1=None): | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment