Skip to content

Conversation

@garrett4wade
Copy link
Collaborator

Description

Merged terminate_process_tree from vllm_server.py and kill_process_tree from utils/proc.py into a single unified function in areal/utils/proc.py.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not
    work as expected)
  • Documentation update
  • Code refactoring (no functional changes)
  • Performance improvement
  • Test coverage improvement

Checklist

  • I have read the Contributing Guide
  • I have run formatting tools (pre-commit or manual)
  • I have run relevant unit tests and they pass
  • I have added tests for new functionality
  • I have updated documentation if needed
  • My branch is up to date with main
  • This PR introduces breaking changes (if yes, fill out details below)
  • If this PR changes documentation, I have built and previewed it locally with
    jb build docs
  • No critical issues raised by AI reviewers (/gemini review)

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @garrett4wade, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors the codebase by unifying disparate process termination mechanisms into a single, robust kill_process_tree utility. This change eliminates code duplication, enhances maintainability, and provides a consistent, configurable approach to gracefully or forcefully shutting down processes and their children across the application.

Highlights

  • Centralized Process Termination: Consolidated multiple, duplicated process termination functions (terminate_process_tree and kill_process_tree) into a single, unified kill_process_tree utility located in areal/utils/proc.py.
  • Enhanced kill_process_tree Functionality: The new utility function provides flexible options for process termination, including graceful shutdown (SIGTERM followed by SIGKILL if necessary), immediate force-killing, configurable timeouts, and the ability to include/exclude the parent process or skip specific child processes.
  • Codebase-Wide Adoption: All previous instances of custom process termination logic and calls to the old duplicated functions have been replaced with calls to the new areal.utils.proc.kill_process_tree.
  • Dependency Streamlining: Removed redundant imports of psutil, signal, and threading from various files, centralizing these dependencies within the new areal/utils/proc.py module.
  • Updated Test Coverage: Existing unit tests related to process termination have been updated to utilize and verify the behavior of the new unified kill_process_tree function.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request is a great refactoring that successfully merges duplicated process termination logic into a single, well-documented utility function kill_process_tree. This change significantly improves code maintainability and consistency across the project. The new function is more robust, handling both graceful and aggressive termination, and its adoption simplifies the cleanup logic in multiple modules. The accompanying test updates are also well-executed, making the tests for this functionality cleaner and more direct. I've found one potential issue in the new utility function that could lead to orphaned child processes and have left a comment with a suggested fix. Overall, this is a high-quality contribution.

@garrett4wade garrett4wade added the safe-to-test Ready to run unit-tests in a PR. label Nov 28, 2025
garrett4wade and others added 2 commits November 30, 2025 13:48
…kill_process_tree

Merged `terminate_process_tree` from vllm_server.py and `kill_process_tree` from utils/proc.py into a single unified function in areal/utils/proc.py.

Key changes:
- Created unified kill_process_tree with graceful termination as default
- Supports both graceful (SIGTERM → wait → SIGKILL) and aggressive (immediate SIGKILL) modes
- Preserves all features: configurable timeout, skip_pid, include_parent, SIGCHLD cleanup, SIGQUIT fallback
- Updated all call sites across areal/ to use the unified function
- Updated tests to mock the centralized implementation

Benefits:
- Eliminates code duplication (3 implementations → 1)
- Consistent process cleanup behavior across the codebase
- Better maintainability with single source of truth

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@garrett4wade garrett4wade added safe-to-test Ready to run unit-tests in a PR. and removed safe-to-test Ready to run unit-tests in a PR. labels Nov 30, 2025
Copy link
Collaborator

@nuzant nuzant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@nuzant nuzant merged commit 87bd3c3 into main Dec 1, 2025
7 checks passed
@nuzant nuzant deleted the fw/kill-proc branch December 1, 2025 02:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe-to-test Ready to run unit-tests in a PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants