Skip to content

Commit 7a7857a

Browse files
committed
remove locks
1 parent 39417c0 commit 7a7857a

File tree

1 file changed

+35
-41
lines changed

1 file changed

+35
-41
lines changed

tests/aws/services/transcribe/test_transcribe.py

Lines changed: 35 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
LOG = logging.getLogger(__name__)
2424

2525
# Lock and event to ensure that the installation is executed before the tests
26-
INIT_VOSK_LOCK = threading.Lock()
27-
INIT_FFMPEG_LOCK = threading.Lock()
2826
vosk_installed = threading.Event()
2927
ffmpeg_installed = threading.Event()
3028
installation_errored = threading.Event()
@@ -41,49 +39,45 @@ def install_async():
4139
return
4240

4341
def install_vosk(*args):
44-
with INIT_VOSK_LOCK:
45-
if vosk_installed.is_set():
46-
return
47-
try:
48-
LOG.info("installing Vosk default version")
49-
vosk_package.install()
50-
LOG.info("done installing Vosk default version")
42+
if vosk_installed.is_set():
43+
return
44+
try:
45+
LOG.info("installing Vosk default version")
46+
vosk_package.install()
47+
LOG.info("done installing Vosk default version")
48+
LOG.info("downloading Vosk models used in test: %s", PRE_DOWNLOAD_LANGUAGE_CODE_MODELS)
49+
for language_code in PRE_DOWNLOAD_LANGUAGE_CODE_MODELS:
50+
model_name = LANGUAGE_MODELS[language_code]
51+
# downloading the model takes quite a while sometimes
52+
TranscribeProvider.download_model(model_name)
5153
LOG.info(
52-
"downloading Vosk models used in test: %s", PRE_DOWNLOAD_LANGUAGE_CODE_MODELS
54+
"done downloading Vosk model '%s' for language code '%s'",
55+
model_name,
56+
language_code,
5357
)
54-
for language_code in PRE_DOWNLOAD_LANGUAGE_CODE_MODELS:
55-
model_name = LANGUAGE_MODELS[language_code]
56-
# downloading the model takes quite a while sometimes
57-
TranscribeProvider.download_model(model_name)
58-
LOG.info(
59-
"done downloading Vosk model '%s' for language code '%s'",
60-
model_name,
61-
language_code,
62-
)
63-
LOG.info("done downloading all Vosk models used in test")
64-
except Exception:
65-
LOG.exception("Error during installation of Vosk dependencies")
66-
installation_errored.set()
67-
# we also set the other event to quickly stop the polling
68-
ffmpeg_installed.set()
69-
finally:
70-
vosk_installed.set()
58+
LOG.info("done downloading all Vosk models used in test")
59+
except Exception:
60+
LOG.exception("Error during installation of Vosk dependencies")
61+
installation_errored.set()
62+
# we also set the other event to quickly stop the polling
63+
ffmpeg_installed.set()
64+
finally:
65+
vosk_installed.set()
7166

7267
def install_ffmpeg(*args):
73-
with INIT_FFMPEG_LOCK:
74-
if ffmpeg_installed.is_set():
75-
return
76-
try:
77-
LOG.info("installing ffmpeg default version")
78-
ffmpeg_package.install()
79-
LOG.info("done ffmpeg default version")
80-
except Exception:
81-
LOG.exception("Error during installation of Vosk dependencies")
82-
installation_errored.set()
83-
# we also set the other event to quickly stop the polling
84-
vosk_installed.set()
85-
finally:
86-
ffmpeg_installed.set()
68+
if ffmpeg_installed.is_set():
69+
return
70+
try:
71+
LOG.info("installing ffmpeg default version")
72+
ffmpeg_package.install()
73+
LOG.info("done ffmpeg default version")
74+
except Exception:
75+
LOG.exception("Error during installation of Vosk dependencies")
76+
installation_errored.set()
77+
# we also set the other event to quickly stop the polling
78+
vosk_installed.set()
79+
finally:
80+
ffmpeg_installed.set()
8781

8882
# we parallelize the installation of the dependencies
8983
# TODO: we could maybe use a ThreadPoolExecutor to use Future instead of manually checking

0 commit comments

Comments
 (0)