mirror of
https://github.com/gradio-app/gradio.git
synced 2025-02-23 11:39:17 +08:00
* changes * changes * revert changes * changes * add changeset * notebooks script * changes * changes --------- Co-authored-by: Ali Abid <aliabid94@gmail.com> Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com>
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
import gradio as gr
|
|
import time
|
|
import random
|
|
|
|
n_calls = 0
|
|
|
|
def get_random_number():
|
|
global n_calls
|
|
if n_calls == 1:
|
|
n_calls += 1
|
|
raise gr.Error("This is a gradio error")
|
|
n_calls += 1
|
|
time.sleep(5)
|
|
return random.randrange(1, 10)
|
|
|
|
with gr.Blocks() as demo:
|
|
with gr.Row():
|
|
with gr.Column():
|
|
first = gr.Button("First Call")
|
|
second = gr.Button("Second Call")
|
|
third = gr.Button("Third Call")
|
|
fourth = gr.Button("Fourth Call")
|
|
with gr.Column():
|
|
first_o = gr.Number(label="First Result")
|
|
second_o = gr.Number(label="Second Result")
|
|
third_o = gr.Number(label="Third Result")
|
|
fourth_o = gr.Number(label="Fourth Result")
|
|
|
|
first.click(get_random_number, None, first_o, concurrency_id="f")
|
|
second.click(get_random_number, None, second_o, concurrency_id="f")
|
|
third.click(get_random_number, None, third_o, concurrency_id="f")
|
|
fourth.click(get_random_number, None, fourth_o, concurrency_id="f")
|
|
|
|
demo.queue(max_size=2)
|
|
|
|
if __name__ == "__main__":
|
|
demo.launch()
|