No-op in netcache run/post_run if nocache is true

When a task class has a true value for the nocache attribute,
setup_nocache doesn't decorate the run() and post_run() methods of the
class. In most cases, however, that's not enough to disable caching
because the base Task class is still modified; any class based on Task
which doesn't override these methods will still use caching even if it
sets nocache to True. This is solved by having the decorated versions of
run() and post_run() do nothing except call the original version of the
method when the task object has a true value for self.nocache.
This commit is contained in:
Ivan Tubert-Brohman 2016-01-25 10:37:08 -05:00 committed by Thomas Nagy
parent 2a7e0de018
commit 9a7381b20e
No known key found for this signature in database
GPG Key ID: 67A565EDFDF90E64
1 changed files with 4 additions and 0 deletions

View File

@ -321,6 +321,8 @@ def make_cached(cls):
m1 = cls.run
def run(self):
if getattr(self, 'nocache', False):
return m1(self)
if self.can_retrieve_cache():
return 0
return m1(self)
@ -328,6 +330,8 @@ def make_cached(cls):
m2 = cls.post_run
def post_run(self):
if getattr(self, 'nocache', False):
return m2(self)
bld = self.generator.bld
ret = m2(self)
if bld.cache_global: