Bugfix for context reference issue
-import types
import functools
-from typing import Any, Callable, Optional, Dict, List # noqa
+import types
+from typing import Any, Callable, Dict, List, Optional # noqa
FUNCTION_ATTRIBUTE = 'TOMODACHI_INVOKER'
START_ATTRIBUTE = 'TOMODACHI_INVOKER_START'
@@ -20,6 +20,9 @@ class Invoker(object):
setattr(_decorator, START_ATTRIBUTE, False)
if not cls.context.get(obj, None):
+ if getattr(obj, "context", None):
+ cls.context[obj] = obj.context
+ else:
cls.context[obj] = {i: getattr(obj, i) for i in dir(obj) if not callable(i) and not i.startswith("__") and not isinstance(getattr(obj, i), types.MethodType)}
context = cls.context[obj]
obj.context = context
