e768098d0e
tools_continuous_delivery / Private PyPI non-main branch release (push) Has been skipped
tools_continuous_delivery / Private PyPI main branch release (push) Failing after 2m42s
Publish Promptflow Doc / Build (push) Has been cancelled
Publish Promptflow Doc / Deploy (push) Has been cancelled
Flake8 Lint / flake8 (push) Has been cancelled
Spell check CI / Spell_Check (push) Has been cancelled
27 lines
679 B
Python
27 lines
679 B
Python
import asyncio
|
|
import os
|
|
import random
|
|
|
|
from fastapi import FastAPI
|
|
|
|
random.seed(42)
|
|
app = FastAPI()
|
|
|
|
|
|
@app.get("/")
|
|
async def wait_and_return():
|
|
|
|
min_wait_time_sec = int(os.getenv("MIN_WAIT_TIME_SEC", 1))
|
|
max_wait_time_sec = int(os.getenv("MAX_WAIT_TIME_SEC", 5))
|
|
|
|
# generate a random number of seconds to sleep between min and max.
|
|
random_float = random.uniform(min_wait_time_sec, max_wait_time_sec)
|
|
await asyncio.sleep(random_float)
|
|
|
|
# return a message to say just how long the service waited for
|
|
return {
|
|
"total_time_sec": random_float,
|
|
"min_wait_time_sec": min_wait_time_sec,
|
|
"max_wait_time_sec": max_wait_time_sec,
|
|
}
|