mirror of
https://github.com/gradio-app/gradio.git
synced 2025-04-06 12:30:29 +08:00
fix: handling SIGINT correctly in reload.py, single entrance of block_thread in blocks.py (#8158)
* fix: handling SIGINT, single block_thread and fix popen * Use pass --------- Co-authored-by: freddyaboulton <alfonsoboulton@gmail.com>
This commit is contained in:
parent
2471f79527
commit
5671ff129a
5
.changeset/cold-spies-fail.md
Normal file
5
.changeset/cold-spies-fail.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"gradio": patch
|
||||
---
|
||||
|
||||
fix:fix: handling SIGINT correctly in reload.py, single entrance of block_thread in blocks.py
|
@ -2427,18 +2427,21 @@ Received outputs:
|
||||
}
|
||||
analytics.launched_analytics(self, data)
|
||||
|
||||
# Block main thread if debug==True
|
||||
if debug or int(os.getenv("GRADIO_DEBUG", "0")) == 1 and not wasm_utils.IS_WASM:
|
||||
self.block_thread()
|
||||
# Block main thread if running in a script to stop script from exiting
|
||||
is_in_interactive_mode = bool(getattr(sys, "ps1", sys.flags.interactive))
|
||||
|
||||
# Block main thread if debug==True
|
||||
if (
|
||||
not prevent_thread_lock
|
||||
and not is_in_interactive_mode
|
||||
# In the Wasm env, we don't have to block the main thread because the server won't be shut down after the execution finishes.
|
||||
# Moreover, we MUST NOT do it because there is only one thread in the Wasm env and blocking it will stop the subsequent code from running.
|
||||
debug
|
||||
or int(os.getenv("GRADIO_DEBUG", "0")) == 1
|
||||
and not wasm_utils.IS_WASM
|
||||
or (
|
||||
# Block main thread if running in a script to stop script from exiting
|
||||
not prevent_thread_lock
|
||||
and not is_in_interactive_mode
|
||||
# In the Wasm env, we don't have to block the main thread because the server won't be shut down after the execution finishes.
|
||||
# Moreover, we MUST NOT do it because there is only one thread in the Wasm env and blocking it will stop the subsequent code from running.
|
||||
and not wasm_utils.IS_WASM
|
||||
)
|
||||
):
|
||||
self.block_thread()
|
||||
|
||||
|
@ -126,7 +126,11 @@ def main(
|
||||
GRADIO_WATCH_DEMO_PATH=str(path),
|
||||
),
|
||||
)
|
||||
popen.wait()
|
||||
if popen.poll() is None:
|
||||
try:
|
||||
popen.wait()
|
||||
except (KeyboardInterrupt, OSError):
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Loading…
x
Reference in New Issue
Block a user