Skip to content

Commit 5204901

Browse files
committed
Try to avoid APIError
1 parent ac4edf8 commit 5204901

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

asgi_bench/runner.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,12 @@ def _write_results(self, target: str, spec: TestSpec, results: dict[str, Any]) -
134134
def _run_image(self, image: str) -> Container:
135135
for container in self.docker_client.containers.list(ignore_removed=True):
136136
if image in container.image.tags:
137-
container.kill()
137+
try:
138+
container.kill()
139+
except APIError as error:
140+
if error.status_code != 409 or "not running" not in error.explanation:
141+
# the container stopped for reasons
142+
raise error
138143
return self.docker_client.containers.run(image=image, ports={SERVER_PORT: SERVER_PORT}, detach=True)
139144

140145
def _run_bench_in_container(self, *args: str) -> str:

0 commit comments

Comments
 (0)