Skip to content

Commit

Permalink
SC2: run download_data via concurrent.futures (#2704)
Browse files Browse the repository at this point in the history
  • Loading branch information
Berserker66 authored Jan 11, 2024
1 parent ac2387e commit 44de140
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions worlds/sc2wol/Client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import asyncio
import copy
import ctypes
import json
import logging
import multiprocessing
import os.path
Expand All @@ -15,6 +14,7 @@
import zipfile
import io
import random
import concurrent.futures
from pathlib import Path

# CommonClient import first to trigger ModuleUpdater
Expand Down Expand Up @@ -42,6 +42,7 @@
from NetUtils import ClientStatus, NetworkItem, RawJSONtoTextParser, JSONtoTextParser, JSONMessagePart
from MultiServer import mark_raw

pool = concurrent.futures.ThreadPoolExecutor(1)
loop = asyncio.get_event_loop_policy().new_event_loop()
nest_asyncio.apply(loop)
max_bonus: int = 13
Expand Down Expand Up @@ -210,6 +211,11 @@ def _cmd_set_path(self, path: str = '') -> bool:
def _cmd_download_data(self) -> bool:
"""Download the most recent release of the necessary files for playing SC2 with
Archipelago. Will overwrite existing files."""
pool.submit(self._download_data)
return True

@staticmethod
def _download_data() -> bool:
if "SC2PATH" not in os.environ:
check_game_install_path()

Expand All @@ -220,7 +226,7 @@ def _cmd_download_data(self) -> bool:
metadata = None

tempzip, metadata = download_latest_release_zip(DATA_REPO_OWNER, DATA_REPO_NAME, DATA_API_VERSION,
metadata=metadata, force_download=True)
metadata=metadata, force_download=True)

if tempzip != '':
try:
Expand Down

0 comments on commit 44de140

Please sign in to comment.