mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-04-19 01:00:45 +01:00
utils/exec_control: Fix once decorator implementation
Ensures that the once decorator does not affect classes in a parallel inheritance hierarchy.
This commit is contained in:
parent
b0262e5103
commit
f26d819aad
@ -1,5 +1,3 @@
|
|||||||
from inspect import getmro
|
|
||||||
|
|
||||||
# "environment" management:
|
# "environment" management:
|
||||||
__environments = {}
|
__environments = {}
|
||||||
__active_environment = None
|
__active_environment = None
|
||||||
@ -96,10 +94,7 @@ def once(method):
|
|||||||
if __active_environment is None:
|
if __active_environment is None:
|
||||||
activate_environment('default')
|
activate_environment('default')
|
||||||
|
|
||||||
func_id = repr(method.func_name)
|
func_id = repr(method.__code__)
|
||||||
# Store the least derived class, which isn't object, to account
|
|
||||||
# for subclasses.
|
|
||||||
func_id += repr(getmro(args[0].__class__)[-2])
|
|
||||||
|
|
||||||
if func_id in __environments[__active_environment]:
|
if func_id in __environments[__active_environment]:
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user