mirror of https://github.com/docker/docker-py.git
avoid race condition in containers.list
Signed-off-by: Ben Doan <ben@bendoan.me>
This commit is contained in:
parent
827bd98d07
commit
b3ae4d6ebd
|
|
@ -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):
|
||||||
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)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue