Uses flags for all checks
They get a lot less complicated, and I have to chase fewer bugs
This commit is contained in:
@@ -102,6 +102,8 @@ class ImageRepo(ABC):
|
|||||||
|
|
||||||
self._data_loaded = False
|
self._data_loaded = False
|
||||||
"""A flag for when the data has been successfully loaded."""
|
"""A flag for when the data has been successfully loaded."""
|
||||||
|
self._data_downloaded = False
|
||||||
|
"""A flag for when the data has been successfully downloaded."""
|
||||||
self._load_lock = Condition(Lock())
|
self._load_lock = Condition(Lock())
|
||||||
"""A lock for enforcing thread safety when loading this repository."""
|
"""A lock for enforcing thread safety when loading this repository."""
|
||||||
self._download_lock = Condition(Lock())
|
self._download_lock = Condition(Lock())
|
||||||
@@ -122,7 +124,7 @@ class ImageRepo(ABC):
|
|||||||
|
|
||||||
:returns: True if the data has been fully loaded, false otherwise.
|
:returns: True if the data has been fully loaded, false otherwise.
|
||||||
"""
|
"""
|
||||||
return not self._load_lock._lock.locked() and self._data_loaded
|
return self._data_loaded
|
||||||
|
|
||||||
def is_downloaded(self):
|
def is_downloaded(self):
|
||||||
"""
|
"""
|
||||||
@@ -130,7 +132,7 @@ class ImageRepo(ABC):
|
|||||||
|
|
||||||
:returns: True if the images have been fully downloaded, false otherwise.
|
:returns: True if the images have been fully downloaded, false otherwise.
|
||||||
"""
|
"""
|
||||||
return not self.image_urls or (not self._download_lock._lock.locked() and self.images)
|
return self._data_downloaded
|
||||||
|
|
||||||
def load_data(self):
|
def load_data(self):
|
||||||
"""
|
"""
|
||||||
@@ -202,6 +204,7 @@ class ImageRepo(ABC):
|
|||||||
logging.info("Downloading %s", self.get_identifier_string())
|
logging.info("Downloading %s", self.get_identifier_string())
|
||||||
self._download_data()
|
self._download_data()
|
||||||
logging.info("Completed downloading of %s", self.get_identifier_string())
|
logging.info("Completed downloading of %s", self.get_identifier_string())
|
||||||
|
self._data_downloaded = True
|
||||||
self._download_lock.notify_all()
|
self._download_lock.notify_all()
|
||||||
|
|
||||||
def await_download(self):
|
def await_download(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user