fix: check that cid is not none before removing

This commit is contained in:
gmega 2025-01-27 20:02:32 -03:00
parent ee67a92726
commit 34a179b110
No known key found for this signature in database
GPG Key ID: 6290D34EAD824B18

View File

@ -110,14 +110,17 @@ class StaticDisseminationExperiment(
def teardown(self, exception: Optional[Exception] = None):
def _remove(element: Tuple[int, Node[TNetworkHandle, TInitialMetadata]]):
index, node = element
assert self._cid is not None # to please mypy
# This means this node didn't even get to seed anything.
if self._cid is None:
return element
# Since teardown might be called as the result of an exception, it's expected
# that not all removes will succeed, so we don't check their result.
node.remove(self._cid)
logger.info("Node %d (%s) removed file", index + 1, node.name)
return element
try:
# Since teardown might be called as the result of an exception, it's expected
# that not all removes will succeed, so we don't check their result.
ensure_successful(
[
self._executor.submit(_remove, (i, node))