From 76e72b1c3f534144ff808b035fbfe596233bfa3c Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Thu, 17 Dec 2020 16:56:12 +0100 Subject: [PATCH] objectstore: keep strong reference of objects The objectstore always tracked all objects that were returned from it, but it did so via weak references, which means it did not keep the objects alive itself. With the introduction of identifiers for temporary objects (floating objects), it makes sense to keep all created objects alive so that they can in fact be used. --- osbuild/objectstore.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osbuild/objectstore.py b/osbuild/objectstore.py index 70d90ec1..a24e6fdc 100644 --- a/osbuild/objectstore.py +++ b/osbuild/objectstore.py @@ -4,7 +4,6 @@ import hashlib import os import subprocess import tempfile -import weakref from typing import Optional from osbuild.util.types import PathLike @@ -249,7 +248,7 @@ class ObjectStore(contextlib.AbstractContextManager): os.makedirs(self.objects, exist_ok=True) os.makedirs(self.refs, exist_ok=True) os.makedirs(self.tmp, exist_ok=True) - self._objs = weakref.WeakSet() + self._objs = set() def _get_floating(self, object_id: str) -> Optional[Object]: """Internal: get a non-committed object"""