Kaydet (Commit) b3ae4d6e authored tarafından Ben Doan's avatar Ben Doan Kaydeden (comit) Joffrey F

avoid race condition in containers.list

Signed-off-by: 's avatarBen Doan <ben@bendoan.me>
üst 827bd98d
...@@ -6,7 +6,7 @@ from ..api import APIClient ...@@ -6,7 +6,7 @@ from ..api import APIClient
from ..constants import DEFAULT_DATA_CHUNK_SIZE from ..constants import DEFAULT_DATA_CHUNK_SIZE
from ..errors import ( from ..errors import (
ContainerError, DockerException, ImageNotFound, ContainerError, DockerException, ImageNotFound,
create_unexpected_kwargs_error NotFound, create_unexpected_kwargs_error
) )
from ..types import HostConfig from ..types import HostConfig
from ..utils import version_gte from ..utils import version_gte
...@@ -896,7 +896,14 @@ class ContainerCollection(Collection): ...@@ -896,7 +896,14 @@ class ContainerCollection(Collection):
if sparse: if sparse:
return [self.prepare_model(r) for r in resp] return [self.prepare_model(r) for r in resp]
else: else:
return [self.get(r['Id']) for r in resp] containers = []
for r in resp:
try:
containers.append(self.get(r['Id']))
# a container may have been removed while iterating
except NotFound:
pass
return containers
def prune(self, filters=None): def prune(self, filters=None):
return self.client.api.prune_containers(filters=filters) return self.client.api.prune_containers(filters=filters)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment