From 1e1c549e695cf6541c4dcac5d554c852165e7b6a Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Wed, 10 May 2017 13:36:51 +0200 Subject: [PATCH 1/4] added missing parameter to function ensure_installed --- lib/galaxy/tools/deps/installable.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/galaxy/tools/deps/installable.py b/lib/galaxy/tools/deps/installable.py index 68489dc351cb..c3de102ce868 100644 --- a/lib/galaxy/tools/deps/installable.py +++ b/lib/galaxy/tools/deps/installable.py @@ -74,4 +74,4 @@ def _check(): else: return _check() except FileLockException: - return ensure_installed(installable_context, auto_init) + return ensure_installed(installable_context, install_func, auto_init) From a1b8a54ef8009ccf9ac64a699ed848cd56bba283 Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Wed, 10 May 2017 15:40:44 +0200 Subject: [PATCH 2/4] ensure_installed is now iterative instead of recursive --- lib/galaxy/tools/deps/installable.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/galaxy/tools/deps/installable.py b/lib/galaxy/tools/deps/installable.py index c3de102ce868..1eccfd3949dc 100644 --- a/lib/galaxy/tools/deps/installable.py +++ b/lib/galaxy/tools/deps/installable.py @@ -67,11 +67,16 @@ def _check(): if not os.path.lexists(parent_path): os.mkdir(parent_path) - try: - if auto_init and os.access(parent_path, os.W_OK): - with FileLock(os.path.join(parent_path, desc.lower())): + import time + MAX_TRIES = 10 + + for i in range( MAX_TRIES ): + try: + if auto_init and os.access(parent_path, os.W_OK): + with FileLock(os.path.join(parent_path, desc.lower())): + return _check() + else: return _check() - else: - return _check() - except FileLockException: - return ensure_installed(installable_context, install_func, auto_init) + except FileLockException: + time.sleep(1) + raise Exception("Failed to get file lock for %s for %s times" % (os.path.join(parent_path, desc.lower()), MAX_TRIES)) From 349c9c8f10f6f5eeac45c1a14e3b4a6c23cc373e Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Wed, 10 May 2017 15:51:44 +0200 Subject: [PATCH 3/4] version with no repetition at all --- lib/galaxy/tools/deps/installable.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/lib/galaxy/tools/deps/installable.py b/lib/galaxy/tools/deps/installable.py index 1eccfd3949dc..23a9d50e8abc 100644 --- a/lib/galaxy/tools/deps/installable.py +++ b/lib/galaxy/tools/deps/installable.py @@ -67,16 +67,11 @@ def _check(): if not os.path.lexists(parent_path): os.mkdir(parent_path) - import time - MAX_TRIES = 10 - - for i in range( MAX_TRIES ): - try: - if auto_init and os.access(parent_path, os.W_OK): - with FileLock(os.path.join(parent_path, desc.lower())): - return _check() - else: + try: + if auto_init and os.access(parent_path, os.W_OK): + with FileLock(os.path.join(parent_path, desc.lower())): return _check() - except FileLockException: - time.sleep(1) - raise Exception("Failed to get file lock for %s for %s times" % (os.path.join(parent_path, desc.lower()), MAX_TRIES)) + else: + return _check() + except FileLockException: + raise Exception("Failed to get file lock for %s" % os.path.join(parent_path, desc.lower())) From a76547281f59b80acd27ddfa098c97e65a72d81a Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Thu, 11 May 2017 13:35:03 +0200 Subject: [PATCH 4/4] Set timeout for aquiring lock to 5min --- lib/galaxy/tools/deps/installable.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/galaxy/tools/deps/installable.py b/lib/galaxy/tools/deps/installable.py index 23a9d50e8abc..990fb08bd8f2 100644 --- a/lib/galaxy/tools/deps/installable.py +++ b/lib/galaxy/tools/deps/installable.py @@ -69,7 +69,7 @@ def _check(): try: if auto_init and os.access(parent_path, os.W_OK): - with FileLock(os.path.join(parent_path, desc.lower())): + with FileLock(os.path.join(parent_path, desc.lower()), timeout=300): return _check() else: return _check()