def close(self):
        for ct in self.containers:
            if ct:
                try:
                    self.docker.remove_container(container=ct.get('Id'))
                except (errors.DockerException, errors.APIError) as e:
                    LOG.warning('Failed to remove container %s, %s' %
                                (ct.get('Id'), str(e)))

        for img in self.images:
            try:
                self.docker.remove_image(image=img, force=True)
            except (errors.DockerException, errors.APIError) as e:
                LOG.warning('Failed to remove docker image %s, %s' %
                            (img, str(e)))

        if self.work_dir:
            self._remove_cloned_repo(self.work_dir)
            try:
                utils.rm_tree(self.work_dir)
            except __HOLE__ as e:
                if e.errno != errno.ENOENT:
                    LOG.critical('critical: cannot remove dir %s,'
                                 ' disk may be full.' % self.work_dir)

        if self.cloner_image:
            try:
                self.docker.remove_image(image=self.cloner_image, force=True)
            except (errors.DockerException, errors.APIError) as e:
                LOG.error('Error in removing docker image %s, %s' %
                          (self.cloner_image, str(e)))
dataset/ETHPy150Open openstack/solum/solum/worker/app_handlers/base.py/BaseHandler.close