pipeline: separate object creation from access
Check for existing checkpoint in `Pipeline.build_stages` by trying to get the object, instead of just checking for its existence. Later, if no checkpoints were found, i.e. `tree` is `None`, create a new object. This avoids mixing of new object creation and object access.
This commit is contained in:
parent
458e2063c9
commit
2d78a0bbea
1 changed files with 6 additions and 3 deletions
|
|
@ -299,14 +299,17 @@ class Pipeline:
|
|||
# Not in the store yet, need to actually build it, but maybe
|
||||
# an intermediate checkpoint exists: Find the last stage that
|
||||
# already exists in the store and use that as the base.
|
||||
tree = object_store.new()
|
||||
tree = None
|
||||
todo = collections.deque()
|
||||
for stage in reversed(self.stages):
|
||||
if object_store.contains(stage.id):
|
||||
tree.base = stage.id
|
||||
tree = object_store.get(stage.id)
|
||||
if tree:
|
||||
break
|
||||
todo.append(stage) # append right side of the deque
|
||||
|
||||
if not tree:
|
||||
tree = object_store.new()
|
||||
|
||||
# If two run() calls race each-other, two trees will get built
|
||||
# and it is nondeterministic which of them will end up
|
||||
# referenced by the `tree_id` in the content store if they are
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue