giskard-evaluator / validate_queue.py
inoki-giskard's picture
Format code and imports
58c39e0
raw
history blame
536 Bytes
import random
import time
import gradio as gr
def sleep_a_while():
seconds = random.randint(5, 10)
print(f"Working for {seconds} seconds")
start = time.time()
while start + seconds > time.time():
continue
return str(seconds)
with gr.Blocks() as iface:
text = gr.Textbox(label="Slept second")
run_btn = gr.Button("Run")
run_btn.click(sleep_a_while, queue=False, outputs=text, concurrency_limit=1)
if __name__ == "__main__":
iface.queue(max_size=2, default_concurrency_limit=2).launch()