You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by gi...@apache.org on 2020/12/29 13:22:02 UTC

[buildstream] 12/33: WIP: pickle: optionpool: make picklable

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 88f8d686a43d021336bd5b353f2cffb891ba75cb
Author: Angelos Evripiotis <je...@bloomberg.net>
AuthorDate: Tue Apr 2 13:13:03 2019 +0100

    WIP: pickle: optionpool: make picklable
---
 src/buildstream/_options/optionpool.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/buildstream/_options/optionpool.py b/src/buildstream/_options/optionpool.py
index de3af3e..d5dea39 100644
--- a/src/buildstream/_options/optionpool.py
+++ b/src/buildstream/_options/optionpool.py
@@ -56,6 +56,18 @@ class OptionPool():
         self._environment = jinja2.Environment(undefined=jinja2.StrictUndefined)
         self._environment.globals = []
 
+    def __getstate__(self):
+        state = self.__dict__.copy()
+        del state['_environment']
+        return state
+
+    def __setstate__(self, state):
+        self.__dict__.update(state)
+
+        # jinja2 environment, with default globals cleared out of the way
+        self._environment = jinja2.Environment(undefined=jinja2.StrictUndefined)
+        self._environment.globals = []
+
     # load()
     #
     # Loads the options described in the project.conf