Skip to content
Snippets Groups Projects
Commit 076f99e6 authored by Aidan Crowther's avatar Aidan Crowther
Browse files

Add environment variable definition to documentation and disable timeout by default

parent e104eca0
No related branches found
No related tags found
No related merge requests found
...@@ -20,12 +20,13 @@ model_lock = Lock() ...@@ -20,12 +20,13 @@ model_lock = Lock()
# https://opennmt.net/CTranslate2/quantization.html # https://opennmt.net/CTranslate2/quantization.html
last_activity_time = time.time() last_activity_time = time.time()
idle_timeout = int(os.getenv("IDLE_TIMEOUT", 300)) # default to 5 minutes idle_timeout = int(os.getenv("IDLE_TIMEOUT", 0)) # default to being disabled
def monitor_idleness(): def monitor_idleness():
global model global model
if(idle_timeout <= 0): return
while True: while True:
time.sleep(60) # check every minute time.sleep(15)
if time.time() - last_activity_time > idle_timeout: if time.time() - last_activity_time > idle_timeout:
with model_lock: with model_lock:
release_model() release_model()
......
...@@ -15,12 +15,13 @@ model = None ...@@ -15,12 +15,13 @@ model = None
model_lock = Lock() model_lock = Lock()
last_activity_time = time.time() last_activity_time = time.time()
idle_timeout = int(os.getenv("IDLE_TIMEOUT", 300)) # default to 5 minutes idle_timeout = int(os.getenv("IDLE_TIMEOUT", 0)) # default to being disabled
def monitor_idleness(): def monitor_idleness():
global model global model
if(idle_timeout <= 0): return
while True: while True:
time.sleep(60) # check every minute time.sleep(15) # check every minute
if time.time() - last_activity_time > idle_timeout: if time.time() - last_activity_time > idle_timeout:
with model_lock: with model_lock:
release_model() release_model()
......
...@@ -24,3 +24,11 @@ For English-only applications, the `.en` models tend to perform better, especial ...@@ -24,3 +24,11 @@ For English-only applications, the `.en` models tend to perform better, especial
```sh ```sh
export ASR_MODEL_PATH=/data/whisper export ASR_MODEL_PATH=/data/whisper
``` ```
### Configuring the `Model Unloading Timeout`
```sh
export IDLE_TIMEOUT=300
```
After no activity for this period (in seconds), unload the model until it is requested again. When set to 0, there will be no timeout.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment