Skip to content

Commit

Permalink
improved version of the async call
Browse files Browse the repository at this point in the history
  • Loading branch information
mashehu committed May 26, 2023
1 parent 74c4e38 commit 766b87a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions nf_core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,18 @@ def check_if_outdated(current_version=None, remote_version=None, source_url="htt
# Build the URL to check against
source_url = os.environ.get("NFCORE_VERSION_URL", source_url)
source_url = f"{source_url}?v={current_version}"

# Fetch the remote version asynchronously
with concurrent.futures.ThreadPoolExecutor() as executor:
future = executor.submit(fetch_remote_version, source_url)
# Retrieve the remote version in the background
remote_version = future.result()
# check if we have a newer version without blocking the rest of the script
is_outdated = False
remote_version = None
try:
with concurrent.futures.ThreadPoolExecutor() as executor:
future = executor.submit(fetch_remote_version, source_url)
remote_version = future.result()
except Exception as e:
log.debug(f"Could not check for nf-core updates: {e}")
if remote_version is not None:
# Check if we have an available update
is_outdated = Version(remote_version) > Version(current_version)
if Version(remote_version) > Version(current_version):
is_outdated = True
return (is_outdated, current_version, remote_version)


Expand Down

0 comments on commit 766b87a

Please sign in to comment.