You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by tv...@apache.org on 2021/02/04 07:22:39 UTC

[buildstream] 06/22: Revert "WIP: jobpickler, _{, un}reduce_plugincontext"

This is an automated email from the ASF dual-hosted git repository.

tvb pushed a commit to branch aevri/win32_minimal_seemstowork_20190829
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 799cbf0eea09974817d2ba607f023fa1cee8293f
Author: Angelos Evripiotis <je...@bloomberg.net>
AuthorDate: Wed Jul 10 08:58:29 2019 +0100

    Revert "WIP: jobpickler, _{,un}reduce_plugincontext"
    
    This reverts commit 8dc514026627c5dbacc47a970a5ec511786edf69.
---
 src/buildstream/_plugincontext.py             | 13 +++++++++++++
 src/buildstream/_scheduler/jobs/jobpickler.py | 24 ------------------------
 2 files changed, 13 insertions(+), 24 deletions(-)

diff --git a/src/buildstream/_plugincontext.py b/src/buildstream/_plugincontext.py
index c058c58..60d2475 100644
--- a/src/buildstream/_plugincontext.py
+++ b/src/buildstream/_plugincontext.py
@@ -68,6 +68,19 @@ class PluginContext():
         self._alternate_sources = {}
         self._format_versions = format_versions
 
+    def __getstate__(self):
+        import copy
+        state = copy.copy(self.__dict__)
+        del state['_site_source']
+        state['_types'] = {}
+        return state
+
+    def __setstate__(self, state):
+        self.__dict__ = state
+        self._site_source = self._plugin_base.make_plugin_source(
+            searchpath=self._site_plugin_path,
+            identifier='site_plugin-' + self._identifier)
+
     # lookup():
     #
     # Fetches a type loaded from a plugin in this plugin context
diff --git a/src/buildstream/_scheduler/jobs/jobpickler.py b/src/buildstream/_scheduler/jobs/jobpickler.py
index 841037c..5c1742f 100644
--- a/src/buildstream/_scheduler/jobs/jobpickler.py
+++ b/src/buildstream/_scheduler/jobs/jobpickler.py
@@ -28,7 +28,6 @@ from ..._protos.buildstream.v2.artifact_pb2 import Artifact as ArtifactProto
 from ... import Element, Source
 from ..._loader import Loader
 from ..._messenger import Messenger
-from ..._plugincontext import PluginContext
 
 
 def _reduce_artifact_proto(instance):
@@ -54,7 +53,6 @@ def _reduce_loader(instance):
     # time that seems just right is here, when preparing the child process'
     # copy of the Loader.
     #
-    # TODO: move this reduce func to loader.py
     del state['_fetch_subprojects']
 
     return (Loader.__new__, (Loader,), state)
@@ -74,32 +72,11 @@ def _reduce_messenger(instance):
     # which removes and restores the _message_handler. This wouldn't require
     # access to private details of Messenger.
     #
-    # TODO: move this reduce func to messenger.py
     del state['_message_handler']
 
     return (Messenger.__new__, (Messenger,), state)
 
 
-def _reduce_plugincontext(instance):
-    assert isinstance(instance, PluginContext)
-    state = instance.__dict__.copy()
-    del state['_site_source']
-    state['_types'] = {}
-
-    # TODO: move this reduce func to plugincontext.py
-
-    return (_unreduce_plugincontext, (state,))
-
-
-def _unreduce_plugincontext(state):
-    instance = PluginContext()
-    instance.__dict__ = state
-    instance._site_source = instance._plugin_base.make_plugin_source(
-        searchpath=instance._site_plugin_path,
-        identifier='site_plugin-' + instance._identifier)
-    return instance
-
-
 def _reduce_element(element):
     assert isinstance(element, Element)
     meta_kind = element._meta_kind
@@ -162,7 +139,6 @@ def pickle_child_job(child_job, context):
     pickler.dispatch_table[ArtifactProto] = _reduce_artifact_proto
     pickler.dispatch_table[Loader] = _reduce_loader
     pickler.dispatch_table[Messenger] = _reduce_messenger
-    pickler.dispatch_table[PluginContext] = _reduce_plugincontext
 
     pickler.dump(child_job)
     data.seek(0)