Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
Don't defer docker whitelist check to another thread
Browse files Browse the repository at this point in the history
This check is not time-consuming so it can be performed in the calling
thread instead of being deferred to another thread.

Actually, this is a workaround for integration tests failing on Windows.
For some reason if database was used in another thread (as it happened
before this change) the unit test cleanup would fail because "The
golem.db is used by another process and cannot be removed".
  • Loading branch information
Wiezzel committed Jul 4, 2019
1 parent fb625cc commit 45cd524
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions golem/envs/docker/cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
NamedTuple, Tuple, Iterator, Union, Iterable

from docker.errors import APIError
from twisted.internet.defer import Deferred, inlineCallbacks
from twisted.internet.defer import Deferred, inlineCallbacks, succeed
from twisted.internet.threads import deferToThread
from urllib3.contrib.pyopenssl import WrappedSocket

Expand Down Expand Up @@ -580,13 +580,14 @@ def install_prerequisites(self, prerequisites: Prerequisites) -> Deferred:
f"is in invalid state: '{self._status}'")
logger.info("Preparing prerequisites...")

if not Whitelist.is_whitelisted(prerequisites.image):
logger.info(
"Docker image '%s' is not whitelisted.",
prerequisites.image,
)
return succeed(False)

def _prepare():
if not Whitelist.is_whitelisted(prerequisites.image):
logger.info(
"Docker image '%s' is not whitelisted.",
prerequisites.image,
)
return False
try:
client = local_client()
client.pull(
Expand Down

0 comments on commit 45cd524

Please sign in to comment.