Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyboard interruption does not work when "every" is used (until demo is closed in browser) #7051

Open
1 task done
muerrilla opened this issue Jan 18, 2024 · 0 comments
Open
1 task done
Labels
bug Something isn't working

Comments

@muerrilla
Copy link

muerrilla commented Jan 18, 2024

Describe the bug

Running the code below, if I don't click the Run button, pressing ctrl+c closes the server as it should. But if I click Run and start the "every" event, pressing ctrl+c will print Keyboard interruption in main thread... closing server. but it will not work and the program keeps running. It only works (along with throwing the error below) when I close the demo window in the browser.

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Reproduction

import gradio as gr

def tick():
    print("Running")

with gr.Blocks() as demo:
    run = gr.Button(value="Run")
    cancel = gr.Button(value="Cancel")
    click_event = run.click(tick, None, None, every=1)
    cancel.click(None, None, None, cancels=[click_event])

demo.queue().launch(server_name="127.0.0.1", server_port=15433, inbrowser=True)

Screenshot

No response

Logs

Running on local URL:  http://127.0.0.1:15433

To create a public link, set `share=True` in `launch()`.
Running
Running
Running
Keyboard interruption in main thread... closing server.
Running
Running
Traceback (most recent call last):
  File "C:\Users\Muerrilla\anaconda3\envs\diffusers\Lib\site-packages\gradio\blocks.py", line 2233, in block_thread
    time.sleep(0.1)
KeyboardInterrupt

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "E:\diffusers\gr.py", line 12, in <module>
    demo.queue().launch(server_name="127.0.0.1", server_port=15433, inbrowser=True)
  File "C:\Users\Muerrilla\anaconda3\envs\diffusers\Lib\site-packages\gradio\blocks.py", line 2140, in launch
    self.block_thread()
  File "C:\Users\Muerrilla\anaconda3\envs\diffusers\Lib\site-packages\gradio\blocks.py", line 2237, in block_thread
    self.server.close()
  File "C:\Users\Muerrilla\anaconda3\envs\diffusers\Lib\site-packages\gradio\networking.py", line 76, in close
    self.thread.join()
  File "C:\Users\Muerrilla\anaconda3\envs\diffusers\Lib\threading.py", line 1112, in join
    self._wait_for_tstate_lock()
  File "C:\Users\Muerrilla\anaconda3\envs\diffusers\Lib\threading.py", line 1132, in _wait_for_tstate_lock
    if lock.acquire(block, timeout):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyboardInterrupt
^C

System Info

Gradio Environment Information:
------------------------------
Operating System: Windows
gradio version: 4.14.0
gradio_client version: 0.8.0

------------------------------------------------
gradio dependencies in your environment:

aiofiles: 23.2.1
altair: 5.1.2
fastapi: 0.104.1
ffmpy: 0.3.1
gradio-client==0.8.0 is not installed.
httpx: 0.25.1
huggingface-hub: 0.20.2
importlib-resources: 6.1.1
jinja2: 3.1.2
markupsafe: 2.1.1
matplotlib: 3.8.1
numpy: 1.26.3
orjson: 3.9.10
packaging: 23.2
pandas: 2.1.3
pillow: 10.2.0
pydantic: 2.5.1
pydub: 0.25.1
python-multipart: 0.0.6
pyyaml: 6.0.1
semantic-version: 2.10.0
tomlkit==0.12.0 is not installed.
typer: 0.9.0
typing-extensions: 4.9.0
uvicorn: 0.24.0.post1
authlib; extra == 'oauth' is not installed.
itsdangerous; extra == 'oauth' is not installed.


gradio_client dependencies in your environment:

fsspec: 2023.12.2
httpx: 0.25.1
huggingface-hub: 0.20.2
packaging: 23.2
typing-extensions: 4.9.0
websockets: 11.0.3

Severity

I can work around it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant