Skip to content

Commit 4e33bc0

Browse files
wouterdbinmantaci
authored andcommitted
Make the server work as a child reaper (PR #7786)
# 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)
1 parent 7992123 commit 4e33bc0

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
description: Make the server work as a child reaper
2+
change-type: patch
3+
destination-branches: [master]
4+
sections:
5+
minor-improvement: The server now also cleans up zombie processes, which is convenient when running in a container

‎src/inmanta/server/bootloader.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import importlib
2121
import logging
2222
import pkgutil
23+
from asyncio import FastChildWatcher
2324
from collections.abc import Generator
2425
from pkgutil import ModuleInfo
2526
from types import ModuleType
@@ -100,6 +101,13 @@ def __init__(self, configure_logging: bool = False) -> None:
100101
inmanta_logger_config.apply_options(inmanta_logging.Options())
101102

102103
async def start(self) -> None:
104+
105+
# Use the fast child watcher
106+
# It also servers as a reaper when the server is pid 1 in a container
107+
childwatcher = FastChildWatcher()
108+
childwatcher.attach_loop(asyncio.get_running_loop())
109+
asyncio.set_child_watcher(childwatcher)
110+
103111
db_wait_time: int = config.db_wait_time.get()
104112
if db_wait_time != 0:
105113
# Wait for the database to be up before starting the server

0 commit comments

Comments
 (0)