Skip to content

Commit

Permalink
Make the server work as a child reaper (PR #7786)
Browse files Browse the repository at this point in the history
# Description

Replace standard child watcher with FastChildWatcher

This will cause it to also clean up zombie processes, but we will have to replace this in the near future, as this while subsystem is deprecated python/cpython#94597.

# Self Check:

Strike through any lines that are not applicable (`~~line~~`) then check the box

- [ ] Attached issue to pull request
- [x] Changelog entry
- [x] Type annotations are present
- [x] Code is clear and sufficiently documented
- [x] No (preventable) type errors (check using make mypy or make mypy-diff)
- [x] Sufficient test cases (reproduces the bug/tests the requested feature)
- [x] Correct, in line with design
- [ ] End user documentation is included or an issue is created for end-user documentation (add ref to issue here: )
- [ ] If this PR fixes a race condition in the test suite, also push the fix to the relevant stable branche(s) (see [test-fixes](https://internal.inmanta.com/development/core/tasks/build-master.html#test-fixes) for more info)
  • Loading branch information
wouterdb authored and inmantaci committed Jul 1, 2024
1 parent 7992123 commit 4e33bc0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions changelogs/unreleased/agent_executor_6_5.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
description: Make the server work as a child reaper
change-type: patch
destination-branches: [master]
sections:
minor-improvement: The server now also cleans up zombie processes, which is convenient when running in a container
8 changes: 8 additions & 0 deletions src/inmanta/server/bootloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import importlib
import logging
import pkgutil
from asyncio import FastChildWatcher
from collections.abc import Generator
from pkgutil import ModuleInfo
from types import ModuleType
Expand Down Expand Up @@ -100,6 +101,13 @@ def __init__(self, configure_logging: bool = False) -> None:
inmanta_logger_config.apply_options(inmanta_logging.Options())

async def start(self) -> None:

# Use the fast child watcher
# It also servers as a reaper when the server is pid 1 in a container
childwatcher = FastChildWatcher()
childwatcher.attach_loop(asyncio.get_running_loop())
asyncio.set_child_watcher(childwatcher)

db_wait_time: int = config.db_wait_time.get()
if db_wait_time != 0:
# Wait for the database to be up before starting the server
Expand Down

0 comments on commit 4e33bc0

Please sign in to comment.