forked from phoenix/litellm-mirror
custom timeout decorator
This commit is contained in:
parent
79847145f8
commit
7b2901be9e
10 changed files with 121 additions and 16 deletions
26
litellm/tests/test_timeout.py
Normal file
26
litellm/tests/test_timeout.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
#### What this tests ####
|
||||
# This tests the timeout decorator
|
||||
|
||||
import sys, os
|
||||
import traceback
|
||||
sys.path.insert(0, os.path.abspath('../..')) # Adds the parent directory to the system path
|
||||
import time
|
||||
from litellm import timeout
|
||||
|
||||
@timeout(10)
|
||||
def stop_after_10_s(force_timeout=60):
|
||||
print("Stopping after 10 seconds")
|
||||
time.sleep(10)
|
||||
return
|
||||
|
||||
|
||||
start_time = time.time()
|
||||
|
||||
try:
|
||||
stop_after_10_s(force_timeout=1)
|
||||
except:
|
||||
pass
|
||||
|
||||
end_time = time.time()
|
||||
|
||||
print(f"total time: {end_time-start_time}")
|
Loading…
Add table
Add a link
Reference in a new issue