From 74efc01ccd9f283d8af028fd004fcfa1ecae6111 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Thu, 19 Mar 2020 12:16:37 +0100 Subject: [PATCH 1/6] Retry reading tool conf on IOError I think that might stabilize the test_tool_reload* unit tests. --- lib/galaxy/tools/toolbox/watcher.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/galaxy/tools/toolbox/watcher.py b/lib/galaxy/tools/toolbox/watcher.py index 2a165cae02e..032ba55ec2d 100644 --- a/lib/galaxy/tools/toolbox/watcher.py +++ b/lib/galaxy/tools/toolbox/watcher.py @@ -71,6 +71,8 @@ class ToolConfWatcher(object): def __init__(self, reload_callback, tool_cache=None): self.paths = {} + self.drop_on_next_loop = set() + self.drop_now = set() self.cache = tool_cache self._active = False self._lock = threading.Lock() @@ -131,11 +133,16 @@ class ToolConfWatcher(object): # in rare cases `path` may be deleted between `os.path.exists` calls # and reading the file from the filesystem. We do not want the watcher # thread to die in these cases. - try: - del hashes[path] - del paths[path] - except KeyError: - pass + if path in self.drop_now: + log.warning("'%s' could not be read, removing from watched files") + try: + del hashes[path] + del paths[path] + except KeyError: + pass + else: + log.debug("'%s could not be read") + self.drop_on_next_loop.add(path) if self.cache: self.cache.cleanup() do_reload = True @@ -145,6 +152,8 @@ class ToolConfWatcher(object): do_reload = True if do_reload: self.reload_callback() + self.drop_now = self.drop_on_next_loop + self.drop_on_next_loop = set() self.exit.wait(1) def monitor(self, path): From fbc70dae1904391fd91a53048ebf4a3d68d7e6c5 Mon Sep 17 00:00:00 2001 From: Marius van den Beek Date: Fri, 20 Mar 2020 09:17:45 +0100 Subject: [PATCH 2/6] fix logging Co-Authored-By: Nicola Soranzo --- lib/galaxy/tools/toolbox/watcher.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/galaxy/tools/toolbox/watcher.py b/lib/galaxy/tools/toolbox/watcher.py index 032ba55ec2d..75b5902eff4 100644 --- a/lib/galaxy/tools/toolbox/watcher.py +++ b/lib/galaxy/tools/toolbox/watcher.py @@ -134,7 +134,7 @@ class ToolConfWatcher(object): # and reading the file from the filesystem. We do not want the watcher # thread to die in these cases. if path in self.drop_now: - log.warning("'%s' could not be read, removing from watched files") + log.warning("'%s' could not be read, removing from watched files", path) try: del hashes[path] del paths[path] From 6aea38443f7675d5d704033a1d876ac41cd48df1 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Fri, 20 Mar 2020 09:19:32 +0100 Subject: [PATCH 3/6] Make drop_now and drop_on_next_loop local variables --- lib/galaxy/tools/toolbox/watcher.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/galaxy/tools/toolbox/watcher.py b/lib/galaxy/tools/toolbox/watcher.py index 75b5902eff4..f224bba505a 100644 --- a/lib/galaxy/tools/toolbox/watcher.py +++ b/lib/galaxy/tools/toolbox/watcher.py @@ -71,8 +71,6 @@ class ToolConfWatcher(object): def __init__(self, reload_callback, tool_cache=None): self.paths = {} - self.drop_on_next_loop = set() - self.drop_now = set() self.cache = tool_cache self._active = False self._lock = threading.Lock() @@ -103,6 +101,8 @@ class ToolConfWatcher(object): hashes = {} while self._active and not self.exit.isSet(): do_reload = False + drop_on_next_loop = set() + drop_now = set() with self._lock: paths = list(self.paths.keys()) for path in paths: @@ -133,7 +133,7 @@ class ToolConfWatcher(object): # in rare cases `path` may be deleted between `os.path.exists` calls # and reading the file from the filesystem. We do not want the watcher # thread to die in these cases. - if path in self.drop_now: + if path in drop_now: log.warning("'%s' could not be read, removing from watched files", path) try: del hashes[path] @@ -142,7 +142,7 @@ class ToolConfWatcher(object): pass else: log.debug("'%s could not be read") - self.drop_on_next_loop.add(path) + drop_on_next_loop.add(path) if self.cache: self.cache.cleanup() do_reload = True @@ -152,8 +152,8 @@ class ToolConfWatcher(object): do_reload = True if do_reload: self.reload_callback() - self.drop_now = self.drop_on_next_loop - self.drop_on_next_loop = set() + drop_now = drop_on_next_loop + drop_on_next_loop = set() self.exit.wait(1) def monitor(self, path): From 6208552e187fb67426dbd003be031de6e4ef1e32 Mon Sep 17 00:00:00 2001 From: Marius van den Beek Date: Fri, 20 Mar 2020 18:00:30 +0100 Subject: [PATCH 4/6] Fix removing tools from watched paths Co-Authored-By: Nicola Soranzo --- lib/galaxy/tools/toolbox/watcher.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/galaxy/tools/toolbox/watcher.py b/lib/galaxy/tools/toolbox/watcher.py index f224bba505a..8f0a753fedb 100644 --- a/lib/galaxy/tools/toolbox/watcher.py +++ b/lib/galaxy/tools/toolbox/watcher.py @@ -135,11 +135,9 @@ class ToolConfWatcher(object): # thread to die in these cases. if path in drop_now: log.warning("'%s' could not be read, removing from watched files", path) - try: + del paths[path] + if path in hashes: del hashes[path] - del paths[path] - except KeyError: - pass else: log.debug("'%s could not be read") drop_on_next_loop.add(path) From bc3733204af57c82b118bb06c807b01e3c95c584 Mon Sep 17 00:00:00 2001 From: Nicola Soranzo Date: Fri, 20 Mar 2020 18:21:15 +0100 Subject: [PATCH 5/6] Fix another logging --- lib/galaxy/tools/toolbox/watcher.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/galaxy/tools/toolbox/watcher.py b/lib/galaxy/tools/toolbox/watcher.py index 8f0a753fedb..7733ded05ab 100644 --- a/lib/galaxy/tools/toolbox/watcher.py +++ b/lib/galaxy/tools/toolbox/watcher.py @@ -139,7 +139,7 @@ class ToolConfWatcher(object): if path in hashes: del hashes[path] else: - log.debug("'%s could not be read") + log.debug("'%s could not be read", path) drop_on_next_loop.add(path) if self.cache: self.cache.cleanup() From 25332bdd2f3228cba76fd8c921d41810db96198e Mon Sep 17 00:00:00 2001 From: Nicola Soranzo Date: Fri, 20 Mar 2020 17:24:32 +0000 Subject: [PATCH 6/6] Ensure miniumum virtualenv version for py27-unit build --- .circleci/config.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a87c6269b74..3afbbc0bb98 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -95,7 +95,8 @@ jobs: <<: *set_workdir steps: - *restore_repo_cache - - *install_tox + # Ensure minimum virtualenv version due to https://github.com/pypa/virtualenv/issues/1670 + - run: sudo pip install tox 'virtualenv>=20.0.8' - run: tox -e py27-unit py35_docstring: docker: