This is an automated email from the ASF dual-hosted git repository. github-bot pushed a commit to branch aevri/picklable_jobs in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit b51a0b8ad9f42b43de3056cd5a0dba4edee8fbc4 Author: Angelos Evripiotis <[email protected]> AuthorDate: Wed Apr 10 13:07:14 2019 +0100 WIP: pickle: remove PicklablePluginProxy --- src/buildstream/_elementfactory.py | 2 +- src/buildstream/_plugincontext.py | 45 -------------------------------------- src/buildstream/_sourcefactory.py | 2 +- 3 files changed, 2 insertions(+), 47 deletions(-) diff --git a/src/buildstream/_elementfactory.py b/src/buildstream/_elementfactory.py index 1a99e33..43fac24 100644 --- a/src/buildstream/_elementfactory.py +++ b/src/buildstream/_elementfactory.py @@ -18,7 +18,7 @@ # Tristan Van Berkom <[email protected]> from . import _site -from ._plugincontext import PluginContext, PicklablePluginProxy +from ._plugincontext import PluginContext from .element import Element diff --git a/src/buildstream/_plugincontext.py b/src/buildstream/_plugincontext.py index 3fee59b..0d322c1 100644 --- a/src/buildstream/_plugincontext.py +++ b/src/buildstream/_plugincontext.py @@ -25,51 +25,6 @@ from . import utils from . import _yaml -class PicklablePluginProxy(): - - def __init__(self, plugin_to_proxy, factory, kind): - object.__setattr__(self, '_PicklablePluginProxy__plugin', plugin_to_proxy) - object.__setattr__(self, '_PicklablePluginProxy__factory', factory) - object.__setattr__(self, '_PicklablePluginProxy__kind', kind) - - def __getattr__(self, name): - return getattr(self.__plugin, name) - - def __setattr__(self, name, value): - return setattr(self.__plugin, name, value) - - def __getstate__(self): - # print("Pickling plugin", self.__plugin, repr(self.__plugin)) - plugin_dict = self.__plugin.__dict__.copy() - try: - # We end up with excessive (infinite?) recursion if we keep these. - # TODO: figure out why, pickle is meant to handle cycles. - del plugin_dict["_Element__reverse_dependencies"] - except KeyError as k: - # print(k) - pass - return { - 'factory': self.__factory, - 'kind': self.__kind, - 'plugin_dict': plugin_dict, - } - - def __setstate__(self, state): - factory = state['factory'] - kind = state['kind'] - plugin_dict = state['plugin_dict'] - - cls, _ = factory.lookup(kind) - plugin = cls.__new__(cls) - plugin.__dict__ = plugin_dict - - object.__setattr__(self, '_PicklablePluginProxy__plugin', plugin) - object.__setattr__(self, '_PicklablePluginProxy__factory', factory) - object.__setattr__(self, '_PicklablePluginProxy__kind', kind) - - # print("Unpickled plugin", plugin, repr(plugin)) - - # A Context for loading plugin types # # Args: diff --git a/src/buildstream/_sourcefactory.py b/src/buildstream/_sourcefactory.py index a9f3ff6..eca4b50 100644 --- a/src/buildstream/_sourcefactory.py +++ b/src/buildstream/_sourcefactory.py @@ -18,7 +18,7 @@ # Tristan Van Berkom <[email protected]> from . import _site -from ._plugincontext import PluginContext, PicklablePluginProxy +from ._plugincontext import PluginContext from .source import Source
