Skip to content

Commit 30c5e52

Browse files
committed
refactor(worker): be more explicit about the docker types
1 parent e2c6afd commit 30c5e52

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

docker-app/worker_wrapper/wrapper.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from typing import Any, Iterable
1111

1212
import docker
13+
import docker.errors
1314
import requests
1415
import sentry_sdk
1516
from constance import config
@@ -18,8 +19,6 @@
1819
from django.db import transaction
1920
from django.forms.models import model_to_dict
2021
from django.utils import timezone
21-
from docker.client import DockerClient
22-
from docker.errors import APIError
2322
from docker.models.containers import Container
2423
from qfieldcloud.authentication.models import AuthToken
2524
from qfieldcloud.core.models import (
@@ -648,7 +647,7 @@ def after_docker_exception(self) -> None:
648647

649648

650649
def cancel_orphaned_workers() -> None:
651-
client: DockerClient = docker.from_env()
650+
client: docker.client.DockerClient = docker.from_env()
652651

653652
try:
654653
running_workers: list[Container] = client.containers.list(
@@ -677,6 +676,6 @@ def cancel_orphaned_workers() -> None:
677676
container.kill()
678677
container.remove()
679678
logger.info(f"Cancel orphaned worker {worker_id}")
680-
except APIError:
679+
except docker.errors.APIError:
681680
# Container already removed
682681
pass

0 commit comments

Comments
 (0)