From a1b8a54ef8009ccf9ac64a699ed848cd56bba283 Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Wed, 10 May 2017 15:40:44 +0200 Subject: [PATCH] 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 c3de102ce86..1eccfd3949d 100644 --- a/lib/galaxy/tools/deps/installable.py +++ b/lib/galaxy/tools/deps/installable.py @@ -67,11 +67,16 @@ def ensure_installed(installable_context, install_func, auto_init): 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))