Skip to content

Make Cancel actually terminate process_fn via SIGTERM#46

Draft
saumya-pailwan wants to merge 3 commits into
TEAMuP-dev:mainfrom
saumya-pailwan:issue_44
Draft

Make Cancel actually terminate process_fn via SIGTERM#46
saumya-pailwan wants to merge 3 commits into
TEAMuP-dev:mainfrom
saumya-pailwan:issue_44

Conversation

@saumya-pailwan

Copy link
Copy Markdown

Previously, cancelling a job only removed it from the Gradio SSE queue. The actual process_fn continued running on the server, consuming GPU/CPU resources and causing cancelled jobs to accumulate.

This change runs process_fn inside a separate subprocess managed by a new JobSupervisor. When a job is cancelled, the subprocess is terminated immediately.

Additionally, all examples now wrap gr.Blocks() and launch() inside if name == "main": This is required because Python's multiprocessing spawn mode re-executes the script in child processes. Without this guard, the child process would attempt to start another Gradio server, preventing the actual job from running correctly.

@saumya-pailwan saumya-pailwan marked this pull request as draft June 12, 2026 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant