buildtools: Use separate storage for each function in runonce
authorPetr Viktorin <pviktori@redhat.com>
Fri, 16 Jan 2015 14:24:03 +0000 (15:24 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Tue, 17 Feb 2015 14:41:11 +0000 (15:41 +0100)
The runonce decorator used shared storage for all functions, and
dispatched only on arguments, so a call would be eliminated if
a different runonce function had already been called with the same
arguments.

Use separate storage for each decorated function.

Signed-off-by: Petr Viktorin <pviktori@redhat.com>
Reviewed-by: Simo Sorce <simo@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
buildtools/wafsamba/samba_utils.py

index 9ac10666f391771de9bbbcb20d21c9eceee46f70..df4a552dbeed5b3408444db9b49b7d73389ac61b 100644 (file)
@@ -39,8 +39,8 @@ def GET_TARGET_TYPE(ctx, target):
 # this is used as a decorator to make functions only
 # run once. Based on the idea from
 # http://stackoverflow.com/questions/815110/is-there-a-decorator-to-simply-cache-function-return-values
-runonce_ret = {}
 def runonce(function):
+    runonce_ret = {}
     def runonce_wrapper(*args):
         if args in runonce_ret:
             return runonce_ret[args]