This method reconstructs the object on the spawned process. The ``state`` argument is constructed by :py:method:`salt.utils.process.Process.__getstate__`. Usually, when subclassing, this method does not need to be implemented, however, if implemented, `super()` **mu
(self, state)
| 945 | |
| 946 | # __setstate__ and __getstate__ are only used on spawning platforms. |
| 947 | def __setstate__(self, state): |
| 948 | """ |
| 949 | This method reconstructs the object on the spawned process. |
| 950 | The ``state`` argument is constructed by :py:method:`salt.utils.process.Process.__getstate__`. |
| 951 | |
| 952 | Usually, when subclassing, this method does not need to be implemented, however, |
| 953 | if implemented, `super()` **must** be called. |
| 954 | """ |
| 955 | args = state["args"] |
| 956 | kwargs = state["kwargs"] |
| 957 | logging_config = state["logging_config"] |
| 958 | # This will invoke __init__ of the most derived class. |
| 959 | self.__init__(*args, **kwargs) |
| 960 | # Override self.__logging_config__ with what's in state |
| 961 | self.__logging_config__ = logging_config |
| 962 | for function, args, kwargs in state["after_fork_methods"]: |
| 963 | self.register_after_fork_method(function, *args, **kwargs) |
| 964 | for function, args, kwargs in state["finalize_methods"]: |
| 965 | self.register_finalize_method(function, *args, **kwargs) |
| 966 | # _INTERNAL_PROCESS_FINALIZE_FUNCTION_LIST lives at module scope and |
| 967 | # is populated in the parent (e.g. by gitfs registering its lock |
| 968 | # cleanup). Under fork the child inherits it via memory copy, but |
| 969 | # forkserver/spawn give us a fresh interpreter where the list is |
| 970 | # empty -- breaking SIGTERM-triggered cleanup hooks. Re-seed it |
| 971 | # from the pickled parent state so cleanup_finalize_process has |
| 972 | # something to iterate. |
| 973 | for function, args, kwargs in state.get("internal_finalize_functions", []): |
| 974 | register_cleanup_finalize_function(function, *args, **kwargs) |
| 975 | |
| 976 | def __getstate__(self): |
| 977 | """ |
nothing calls this directly
no test coverage detected