1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-23 09:57:40 +03:00

buildtools: Use separate storage for each function in runonce

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>
This commit is contained in:
Petr Viktorin 2015-01-16 15:24:03 +01:00 committed by Andreas Schneider
parent fcf4a89194
commit a0cbce60f4

View 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]