[elbe-devel] [PATCH 3/7] elbepack: elbexml: make ElbeXML picklable
Thomas Weißschuh
thomas.weissschuh at linutronix.de
Mon Aug 19 16:50:15 CEST 2024
The underlying XML trees are not compatible with pickle.
Instead serialize and deserialize them through a string.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
elbepack/elbexml.py | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/elbepack/elbexml.py b/elbepack/elbexml.py
index 53e82657e138..b9611753fa6d 100644
--- a/elbepack/elbexml.py
+++ b/elbepack/elbexml.py
@@ -85,6 +85,15 @@ class ElbeXML:
if not skip_validate and url_validation != ValidationMode.NO_CHECK:
self.validate_apt_sources(url_validation, self.defs['arch'])
+ def __getstate__(self):
+ state = super().__getstate__().copy()
+ state['xml'] = state['xml'].tostring()
+ return state
+
+ def __setstate__(self, state):
+ state['xml'] = etree(None, string=state['xml'])
+ self.__dict__.update(state)
+
def text(self, txt, key=None):
if key:
return self.xml.text(txt, default=self.defs, key=key)
--
2.46.0
More information about the elbe-devel
mailing list