Skip to content

Commit 44de140

Browse files
authored
SC2: run download_data via concurrent.futures (#2704)
1 parent ac2387e commit 44de140

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

worlds/sc2wol/Client.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import asyncio
44
import copy
55
import ctypes
6-
import json
76
import logging
87
import multiprocessing
98
import os.path
@@ -15,6 +14,7 @@
1514
import zipfile
1615
import io
1716
import random
17+
import concurrent.futures
1818
from pathlib import Path
1919

2020
# CommonClient import first to trigger ModuleUpdater
@@ -42,6 +42,7 @@
4242
from NetUtils import ClientStatus, NetworkItem, RawJSONtoTextParser, JSONtoTextParser, JSONMessagePart
4343
from MultiServer import mark_raw
4444

45+
pool = concurrent.futures.ThreadPoolExecutor(1)
4546
loop = asyncio.get_event_loop_policy().new_event_loop()
4647
nest_asyncio.apply(loop)
4748
max_bonus: int = 13
@@ -210,6 +211,11 @@ def _cmd_set_path(self, path: str = '') -> bool:
210211
def _cmd_download_data(self) -> bool:
211212
"""Download the most recent release of the necessary files for playing SC2 with
212213
Archipelago. Will overwrite existing files."""
214+
pool.submit(self._download_data)
215+
return True
216+
217+
@staticmethod
218+
def _download_data() -> bool:
213219
if "SC2PATH" not in os.environ:
214220
check_game_install_path()
215221

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

222228
tempzip, metadata = download_latest_release_zip(DATA_REPO_OWNER, DATA_REPO_NAME, DATA_API_VERSION,
223-
metadata=metadata, force_download=True)
229+
metadata=metadata, force_download=True)
224230

225231
if tempzip != '':
226232
try:

0 commit comments

Comments
 (0)