File size: 537 Bytes
3573a39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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()