python3.13 likely remains stuck in a busy-poll loop. A diagnosis report and patch proposal were created locally.
Published session
Prompt
## Plan Pass
You are planning a fixer patch before any edits happen.
Read the evidence bundle at `./evidence.json`. The prepared workspace is `./workspace` and it was acquired via `debian-source`. The original pre-edit snapshot is available at `./source` if you need to inspect it. For interpreter processes, plan from the script/application entrypoint evidence first and include the runtime only as a second investigation target unless the evidence proves a runtime bug.
Upstream-style expectation: before planning or editing, check for contribution/style docs (`CONTRIBUTING`, `HACKING`, `README-hacking`, `README.md`, `docs/`, `dev-docs/`) and scan the touched subsystem for local helpers. If the project has wrappers for file IO, path-relative IO, process spawning, memory allocation, logging, locking, or platform compatibility, prefer those wrappers over generic libc/std APIs. Do not invent a reproducer or user-visible failure that is not in the evidence bundle; if the evidence is profiler-only or indirect, describe it as a targeted mitigation or stop with a diagnosis instead of presenting a speculative patch as a confirmed bug fix. In the plan and final validation, name any such helper, convention, or evidence limit you found, or say that no relevant local helper was found. Treat this as a `supervisor` upstream patch, not just a Debian-local workaround. Inspect the relevant code, nearby callers, project contribution docs, and local helper/compat APIs, but do not edit files in this pass.
Return a short markdown plan with these exact sections:
## Problem
## Evidence Confidence
## Proposed Subject
## Patch Plan
## Risks
## Validation
Classify `## Evidence Confidence` as exactly one of `reproduced`, `observed`, or `inferred`. Use `inferred` only for a no-patch diagnosis/report plan unless you can name the extra evidence you will collect before editing; inferred source patches are blocked by Fixer because they are not pull-request-ready. For `observed` source-patch plans, plan to say in the final `## Issue Connection` that the failure was observed by Fixer and not independently reproduced. The plan must explain how the proposed code change addresses the observed issue evidence, call out any prior Fixer patch that should be improved or replaced, reject awkward control flow such as avoidable `goto` if there is a cleaner bounded alternative, name any local helper APIs or maintainer conventions the patch should follow, and keep the intended maintainer-facing explanation clear enough that someone unfamiliar with the local complaint wording can still follow the fix. In `## Validation`, name the reproducible configure/build/test entrypoint you will try from the workspace root before any focused leaf compile or smoke check, and include one bounded independent reproduction attempt for the collected failure signal when it is safe and cheap. Do not plan to claim `reproduced` unless that reproduction command or test can actually show the failure.
## Patch Pass
You are working on a bounded fixer proposal.
Read the evidence bundle at `./evidence.json`. The prepared workspace is `./workspace` and it was acquired via `debian-source`. Produce the smallest reasonable patch for the target repository, keep the change upstreamable, prefer the clearest control flow available, and do not keep avoidable `goto` when a simpler structure would read better. Before introducing new file, process, allocation, locking, networking, or platform APIs, inspect nearby code and project contribution docs for existing helpers or compatibility wrappers and use those local patterns unless you can explain why they do not fit. Validate from a reproducible workspace-root entrypoint before falling back to focused leaf commands; if a build or test cannot run, report the exact command, the exact blocker, and any narrower check you ran instead. During validation, also try one bounded independent reproduction of the collected failure signal when it is safe and cheap, such as a failing test, smoke command, perf/strace comparison, or before/after runtime check. Only use `reproduced` if that command or test actually reproduced the failure; otherwise keep `observed` and report the reproduction blocker. The final explanation must connect the observed issue evidence to the actual code change, not just paraphrase the diff. Write like a maintainer is going to read the patch mail cold: explain the bug in plain language, define subsystem-specific jargon the first time you need it, and make the causal story obvious. Explicitly classify evidence confidence as `reproduced`, `observed`, or `inferred`: `reproduced` means you reproduced the failure locally; `observed` means Fixer has direct crash/log/trace evidence but you did not independently reproduce it; `inferred` means the source patch is not pull-request-ready, so do not leave a source diff unless you first gather stronger observed/reproduced evidence; otherwise return a no-patch diagnosis/report. For any source-changing `observed` patch, say explicitly in `## Issue Connection` that the failure was observed by Fixer and not independently reproduced. If you introduce non-obvious state translation, index remapping, or backend split logic, add a short source comment that explains the invariant being preserved.
Start by explaining the likely root cause from the collected perf, strace, and /proc evidence. If you cannot land a safe patch, leave a diagnosis that is strong enough for an upstream bug report.
Interpreter process expectation: when the hot process is Python, Perl, shell, Node, Ruby, PHP, Lua, or another interpreter, inspect both the runtime and the script/application entrypoint from `details.interpreter_process`. Prefer the script or application package when evidence points there; do not patch the interpreter runtime merely because the hot binary is `python`, `perl`, `bash`, or similar. Runtime fixes are welcome only after checking the entrypoint and explaining why the runtime mishandles the workload or why running bad code faster/safer is itself the right upstream fix.
A previous Fixer patch attempt already exists for this issue. It was generated by Fixer `0.148.0`. Review that patch before changing code, improve it instead of starting blind, and clean up anything awkward or underexplained. In particular, remove avoidable `goto`, tighten the explanation of what the patch is doing, and make the resulting diff feel ready for upstream git review.
- Prior patch: `./prior-best.patch`
- Prior published session: `./prior-best-session.md`
Upstream-style expectation: before planning or editing, check for contribution/style docs (`CONTRIBUTING`, `HACKING`, `README-hacking`, `README.md`, `docs/`, `dev-docs/`) and scan the touched subsystem for local helpers. If the project has wrappers for file IO, path-relative IO, process spawning, memory allocation, logging, locking, or platform compatibility, prefer those wrappers over generic libc/std APIs. Do not invent a reproducer or user-visible failure that is not in the evidence bundle; if the evidence is profiler-only or indirect, describe it as a targeted mitigation or stop with a diagnosis instead of presenting a speculative patch as a confirmed bug fix. In the plan and final validation, name any such helper, convention, or evidence limit you found, or say that no relevant local helper was found. Treat this as a `supervisor` upstream patch, not just a Debian-local workaround.
Keep the change narrowly scoped and summarize validation clearly.
In every authoring pass, your final response must start with `Subject: <single-line git commit subject>` and then include these markdown sections exactly:
## Commit Message
A short upstream-friendly explanation of what changed and why. Write it in plain language that a maintainer can follow without local complaint context. If you use subsystem jargon, define it immediately.
## Evidence Confidence
Exactly one word: `reproduced`, `observed`, or `inferred`. Use `reproduced` only when you reproduced the failure locally with a command or test, and include that command/test in `## Validation`. Use `observed` when Fixer has direct crash/log/trace evidence but you did not independently reproduce it. If `## Git Add Paths` lists source files for an `observed` patch, `## Issue Connection` must explicitly say the failure was observed by Fixer and not independently reproduced. Use `inferred` for profiler/strace/indirect evidence; inferred responses may be no-patch diagnoses or reports, but inferred source patches are not pull-request-ready until stronger evidence is gathered.
## Issue Connection
Write this as maintainer-facing patch mail, not as local Fixer notes. Cover four things explicitly in readable sentences: the user-visible symptom or the exact collected signal, the code-level cause or the cautious inference from evidence, the specific change you made, and the expected effect. Do not invent a reproducer, command line, crash, or user-visible failure that is not present in the evidence bundle. If the evidence is direct-but-not-reproduced, say it was observed by Fixer and not independently reproduced. If the evidence is indirect and you did not gather stronger evidence, do not leave a source diff; write a no-patch diagnosis/report instead. Include an explicit effect sentence such as `The expected effect is ...`, `This should reduce ...`, or `This prevents ...` for source patches. If the logic is non-obvious in code, mention that you added a short explanatory comment.
## Git Add Paths
List the repo-relative paths that belong in the final patch, one per line. Use `None` only when you intentionally made no source changes. Include intentionally new files, and do not list generated build artifacts.
## Validation
List the checks you ran, or say clearly that you could not run them. Include the independent reproduction command/test and result when `## Evidence Confidence` is `reproduced`; if reproduction was attempted but blocked, name the exact blocker and keep confidence at `observed` or `inferred`.
Before editing, read the plan at `./plan-output.txt` and follow it unless the code proves part of it wrong. If you change course, say so explicitly in the final write-up instead of silently drifting from the plan.
## Review Pass 1
You are reviewing a freshly generated fixer patch.
Read the evidence bundle at `./evidence.json`. The prepared workspace is `./workspace` and it was acquired via `debian-source`. Review the first patch pass. The original pre-edit snapshot is available at `./source` for diffing. The workspace currently changes these repo-relative paths: supervisor/supervisord.py, supervisor/tests/base.py, supervisor/tests/test_supervisord.py. Verify that `## Git Add Paths` matches this exact set and that `## Issue Connection` explains every shipped functional file.
Upstream-style expectation: before planning or editing, check for contribution/style docs (`CONTRIBUTING`, `HACKING`, `README-hacking`, `README.md`, `docs/`, `dev-docs/`) and scan the touched subsystem for local helpers. If the project has wrappers for file IO, path-relative IO, process spawning, memory allocation, logging, locking, or platform compatibility, prefer those wrappers over generic libc/std APIs. Do not invent a reproducer or user-visible failure that is not in the evidence bundle; if the evidence is profiler-only or indirect, describe it as a targeted mitigation or stop with a diagnosis instead of presenting a speculative patch as a confirmed bug fix. In the plan and final validation, name any such helper, convention, or evidence limit you found, or say that no relevant local helper was found. Treat this as a `supervisor` upstream patch, not just a Debian-local workaround. The latest author response is at `./patch-output.txt`. Inspect the current code and changed paths like a strict code reviewer. Focus on correctness, regressions, maintainability, awkward control flow such as avoidable `goto`, missing validation, weak or non-gittable commit message text, and explanations that fail to connect the observed issue evidence to the code change. Also review the maintainer experience: the patch mail should be easy to accept upstream, the user-visible bug should be explained in plain language, subsystem-specific jargon should be defined when first used, and any non-obvious state translation or index remapping in code should have a short explanatory comment. Reject patches that omit `## Evidence Confidence`, use anything other than `reproduced`, `observed`, or `inferred`, or sound more certain than that evidence level allows. Reject patches that claim `reproduced` unless `## Validation` names the concrete reproduction command or test and its result. Reject patches that invent a reproducer, command line, crash, or user-visible failure not present in the evidence bundle; indirect profiler or strace evidence may justify a cautious mitigation, but the author must say it is indirect instead of presenting it as a confirmed upstream bug. Reject patches that introduce generic libc/std APIs when nearby code or project docs provide a local compat/helper API for the same job, unless the author explicitly justifies the exception. Reject validation that only reports a leaf object/syntax build when a project-level configure/build/test entrypoint exists and was not attempted; if a full build cannot run, the author must show the exact failed command and blocker.
Do not apply code changes in this pass.
Return a short markdown review report. The first non-empty line must be exactly one of:
RESULT: ok
RESULT: fix-needed
If you choose `RESULT: fix-needed`, add a `## Findings` section with concrete, actionable items.
## Refinement Pass 1
You are refining a fixer patch after an explicit code review.
Read the evidence bundle at `./evidence.json`. The prepared workspace is `./workspace` and it was acquired via `debian-source`. Read the latest author response at `./patch-output.txt`. Read the review report at `./review-1-output.txt`. This is refinement round 1. The original pre-edit snapshot is available at `./source` if you need to compare the current patch against it. Re-read the planning pass at `./plan-output.txt` before editing. The workspace currently changes these repo-relative paths: supervisor/supervisord.py, supervisor/tests/base.py, supervisor/tests/test_supervisord.py. Either keep that exact set synchronized with `## Git Add Paths` and `## Issue Connection`, or revert any unintended file before you answer.
Upstream-style expectation: before planning or editing, check for contribution/style docs (`CONTRIBUTING`, `HACKING`, `README-hacking`, `README.md`, `docs/`, `dev-docs/`) and scan the touched subsystem for local helpers. If the project has wrappers for file IO, path-relative IO, process spawning, memory allocation, logging, locking, or platform compatibility, prefer those wrappers over generic libc/std APIs. Do not invent a reproducer or user-visible failure that is not in the evidence bundle; if the evidence is profiler-only or indirect, describe it as a targeted mitigation or stop with a diagnosis instead of presenting a speculative patch as a confirmed bug fix. In the plan and final validation, name any such helper, convention, or evidence limit you found, or say that no relevant local helper was found. Treat this as a `supervisor` upstream patch, not just a Debian-local workaround. Address the review findings with the smallest reasonable follow-up changes. If the review identifies a runtime or correctness bug in the changed code, you must update the code itself before answering; a metadata-only response is not sufficient. Keep the patch upstream-friendly, use local project helpers and compat APIs when available, avoid awkward control flow when a simpler structure will do, keep the final response gittable, make the maintainer-facing explanation plain and direct, keep `## Evidence Confidence` honest, add short comments for any non-obvious translation or remapping logic, run relevant project-level build/tests from the workspace root before narrower checks when possible, try a bounded independent reproduction command/test if the review or plan shows one is safe, and summarize which review findings you addressed.
In every authoring pass, your final response must start with `Subject: <single-line git commit subject>` and then incl
[truncated 5874 bytes]
Response
## Plan Pass
## Problem
Fixer observed `supervisord` running as `/usr/bin/python3 /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf` with repeated `poll(..., 1000)` timeouts followed by `wait4(-1, ..., WNOHANG) = -1 ECHILD`. The source loop in `supervisor/supervisord.py` calls `self.reap()` every iteration, and `ServerOptions.waitpid()` wraps `os.waitpid(-1, os.WNOHANG)`, so an idle/no-child daemon still performs an unnecessary reap syscall once per loop.
## Evidence Confidence
observed
## Proposed Subject
`supervisord: skip idle child reaping when no child is tracked`
## Patch Plan
Update `Supervisor.runforever()` so signal handling happens before reaping, then call `reap()` only when Supervisor is tracking child PIDs in `options.pidhistory` or when the signal queue reports `SIGCHLD`. Keep using the existing local helpers: `options.get_signal()` through `handle_signal()`, `options.pidhistory`, `Supervisor.reap()`, `ServerOptions.waitpid()`, and the existing `options.poller` abstraction. Do not call `os.waitpid` directly.
Improve or replace the prior Fixer patch at `prior-best.patch`: its direction is reasonable, but the final patch should keep the control flow small and maintainer-readable, add a focused helper or clear local variable if needed, and avoid awkward control flow. Since this is Python, no `goto` applies; the bounded alternative is a straightforward `sig = self.handle_signal()` followed by a single conditional `self.reap()`.
Add tests in `supervisor/tests/test_supervisord.py` using existing `DummyOptions`/`DummyPoller`, extending `DummyOptions.waitpid()` with a call counter, to cover:
- no `waitpid()` call when no PIDs are tracked and no `SIGCHLD` is queued;
- `waitpid()` still called when `pidhistory` is non-empty;
- `waitpid()` still called when `SIGCHLD` is received;
- existing non-`SIGCHLD` signal behavior remains intact.
## Risks
Changing reap timing could delay cleanup of unknown child processes by one loop when a non-`SIGCHLD` signal is ahead of `SIGCHLD` in `SignalReceiver`; tracked children remain protected by `pidhistory`. The evidence is profiler/strace-only and does not prove that this syscall alone explains the reported CPU percentage, so the maintainer-facing explanation should describe this as reducing the observed idle `wait4(ECHILD)` churn, not as a confirmed full CPU fix.
## Validation
From the workspace root, first run the project’s configured test entrypoint: `python3 -m pytest`. Then run the focused test file: `python3 -m pytest supervisor/tests/test_supervisord.py`.
For a bounded independent reproduction attempt, run an idle local `supervisord` with a temporary minimal config under `timeout` and `strace -e wait4,poll` before and after the patch. The pre-patch check should show the observed once-per-loop `wait4(... WNOHANG) = -1 ECHILD`; the post-patch check should show that idle no-child loops no longer issue that reap syscall unless a child is tracked or `SIGCHLD` is queued. In the final `## Issue Connection`, state that the failure signal was observed by Fixer and not independently reproduced unless that strace check actually demonstrates it.
## Patch Pass
Subject: supervisord: skip idle reaps without child activity
## Commit Message
`supervisord` no longer asks the kernel for exited children on every idle main-loop pass when it has no tracked child PIDs and has not received `SIGCHLD`, the child-exit signal. The loop now handles any pending signal first and only calls the existing `options.waitpid()` wrapper when Supervisor is tracking children or when `SIGCHLD` indicates a child may need reaping.
## Evidence Confidence
observed
## Issue Connection
Fixer observed `/usr/bin/python3 /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf` alternating one-second `poll()` timeouts with `wait4(-1, WNOHANG) = -1 ECHILD`, meaning the process was asking for exited children when the kernel reported that there were none. This was observed by Fixer and not independently reproduced as a syscall trace because ptrace/`strace` is blocked in this sandbox.
The hot process was Python, but the evidence identified the script entrypoint as `supervisord`, so the patch targets Supervisor application logic rather than the Python runtime. In `Supervisor.runforever()`, the code previously called `self.reap()` unconditionally after every poll; `reap()` uses Supervisor’s local `options.waitpid()` helper. I followed the saved plan and the prior Fixer patch’s core approach: `handle_signal()` now returns the signal it consumed, and `runforever()` only reaps when `options.pidhistory` has tracked child PIDs or that signal is `SIGCHLD`.
The expected effect is to remove the unnecessary idle `waitpid` path when there are no known children to reap, while preserving normal cleanup for Supervisor-managed children and unknown children announced by `SIGCHLD`. I checked `README.rst`, `docs/development.rst`, `tox.ini`, and the touched subsystem; the relevant local helpers are `options.waitpid()`, `options.get_signal()`/`SignalReceiver`, and `options.poller`, and the patch keeps using them.
## Git Add Paths
supervisor/supervisord.py
supervisor/tests/base.py
supervisor/tests/test_supervisord.py
## Validation
`python3 -m pytest --capture=no`
Ran from the workspace root. Result: 1362 passed, 26 failed. The blockers were existing Python 3.13 `unittest.findTestCases` removals and sandbox socket restrictions raising `PermissionError: [Errno 1] Operation not permitted`.
`python3 -m pytest --capture=no supervisor/tests/test_supervisord.py -k 'not test_suite'`
Result: 43 passed, 1 deselected.
Independent reproduction attempt:
`timeout 3s strace -e trace=wait4,poll -o /tmp/supervisor-fixer-strace.log python3 -m supervisor.supervisord -n -c supervisor/tests/fixtures/donothing.conf`
Result: blocked by ptrace policy: `PTRACE_TRACEME: Operation not permitted`.
Bounded wrapper-level before/after check: one idle `runforever()` iteration in the original snapshot called the `waitpid` wrapper once (`waitpid_calls=1`); the patched workspace called it zero times (`waitpid_calls=0`).
## Review Pass 1
RESULT: fix-needed
## Findings
- `supervisor/tests/test_supervisord.py` has unrelated EOF whitespace churn: the diff removes the final blank line after `unittest.main(defaultTest='test_suite')`. This is not part of the behavioral fix or tests and should be removed so the patch is narrowly scoped.
Everything else looks acceptable: `## Git Add Paths` matches the changed path set exactly, the evidence confidence is correctly `observed`, the response does not claim an independently reproduced syscall trace, and the code keeps using Supervisor’s local `options.waitpid()`, `options.get_signal()`, and `options.poller` conventions.
## Refinement Pass 1
Subject: supervisord: skip idle reaps without child activity
## Commit Message
`supervisord` no longer asks the kernel for exited children on every idle main-loop pass when it has no tracked child PIDs and has not received `SIGCHLD`, the child-exit signal. The loop now handles any pending signal first and only calls the existing `options.waitpid()` wrapper when Supervisor is tracking children or when `SIGCHLD` indicates a child may need reaping.
## Evidence Confidence
observed
## Issue Connection
Fixer observed `/usr/bin/python3 /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf` alternating one-second `poll()` timeouts with `wait4(-1, WNOHANG) = -1 ECHILD`, meaning the process was asking for exited children when the kernel reported that there were none. This was observed by Fixer and not independently reproduced as a syscall trace because ptrace/`strace` is blocked in this sandbox.
The hot process was Python, but the evidence identified the script entrypoint as `supervisord`, so the patch targets Supervisor application logic rather than the Python runtime. In `Supervisor.runforever()`, the code previously called `self.reap()` unconditionally after every poll; `reap()` uses Supervisor’s local `options.waitpid()` helper. The patch makes `handle_signal()` return the signal it consumed, and `runforever()` only reaps when `options.pidhistory` has tracked child PIDs or that signal is `SIGCHLD`.
The expected effect is to remove the unnecessary idle `waitpid` path when there are no known children to reap, while preserving normal cleanup for Supervisor-managed children and unknown children announced by `SIGCHLD`. I checked `README.rst`, `docs/development.rst`, `tox.ini`, and the touched subsystem; the relevant local helpers are `options.waitpid()`, `options.get_signal()`/`SignalReceiver`, and `options.poller`, and the patch keeps using them. Review round 1 only flagged EOF whitespace churn in `supervisor/tests/test_supervisord.py`; that incidental diff has been removed.
## Git Add Paths
supervisor/supervisord.py
supervisor/tests/base.py
supervisor/tests/test_supervisord.py
## Validation
`python3 -m pytest --capture=no`
Ran from the workspace root after the refinement. Result: 1362 passed, 26 failed. The failures are existing Python 3.13 `unittest.findTestCases` removals and sandbox socket restrictions raising `PermissionError: [Errno 1] Operation not permitted`.
`python3 -m pytest --capture=no supervisor/tests/test_supervisord.py -k 'not test_suite'`
Result: 43 passed, 1 deselected.
`git diff --check`
Result: passed.
Independent reproduction attempt: `timeout 3s strace -e trace=wait4,poll -o /tmp/supervisor-fixer-strace.log python3 -m supervisor.supervisord -n -c supervisor/tests/fixtures/donothing.conf` was blocked by ptrace policy: `PTRACE_TRACEME: Operation not permitted`.
Bounded wrapper-level before/after check: one idle `runforever()` iteration in the original snapshot called the `waitpid` wrapper once (`waitpid_calls=1`); the patched workspace called it zero times (`waitpid_calls=0`).
## Review Pass 2
RESULT: ok
No blocking findings.
The refined patch addresses the prior review finding: the unrelated EOF whitespace churn is gone, and `git diff --check` is clean. The workspace changes exactly the expected paths, and `## Git Add Paths` matches them:
`supervisor/supervisord.py`, `supervisor/tests/base.py`, and `supervisor/tests/test_supervisord.py`.
The implementation is narrow, keeps using Supervisor’s local helpers (`options.waitpid()`, `options.get_signal()`/`SignalReceiver`, and `options.poller`), and the control flow is straightforward. The response keeps evidence confidence at `observed`, explicitly says the Fixer signal was not independently reproduced as a syscall trace, and reports both the project-level pytest attempt and the focused validation.
Diff
diff --git a/supervisor/supervisord.py b/supervisor/supervisord.py
index 0a4f3e6..aa455e5 100755
--- a/supervisor/supervisord.py
+++ b/supervisor/supervisord.py
@@ -241,8 +241,9 @@ class Supervisor:
for group in pgroups:
group.transition()
- self.reap()
- self.handle_signal()
+ sig = self.handle_signal()
+ if self.options.pidhistory or sig == signal.SIGCHLD:
+ self.reap()
self.tick()
if self.options.mood < SupervisorStates.RUNNING:
@@ -312,6 +313,7 @@ class Supervisor:
else:
self.options.logger.blather(
'received %s indicating nothing' % signame(sig))
+ return sig
def get_state(self):
return self.options.mood
diff --git a/supervisor/tests/base.py b/supervisor/tests/base.py
index f608b2b..1f25b58 100644
--- a/supervisor/tests/base.py
+++ b/supervisor/tests/base.py
@@ -60,6 +60,7 @@ class DummyOptions:
self.pidfile_written = False
self.directory = None
self.waitpid_return = None, None
+ self.waitpid_calls = 0
self.kills = {}
self._signal = None
self.parent_pipes_closed = None
@@ -145,6 +146,7 @@ class DummyOptions:
self.pidfile_written = True
def waitpid(self):
+ self.waitpid_calls += 1
return self.waitpid_return
def kill(self, pid, sig):
diff --git a/supervisor/tests/test_supervisord.py b/supervisor/tests/test_supervisord.py
index 3d7b4ff..10cebef 100644
--- a/supervisor/tests/test_supervisord.py
+++ b/supervisor/tests/test_supervisord.py
@@ -228,7 +228,8 @@ class SupervisordTests(unittest.TestCase):
options = DummyOptions()
options._signal = signal.SIGTERM
supervisord = self._makeOne(options)
- supervisord.handle_signal()
+ sig = supervisord.handle_signal()
+ self.assertEqual(sig, signal.SIGTERM)
self.assertEqual(supervisord.options.mood,
SupervisorStates.SHUTDOWN)
self.assertEqual(options.logger.data[0],
@@ -284,7 +285,8 @@ class SupervisordTests(unittest.TestCase):
options = DummyOptions()
options._signal = signal.SIGCHLD
supervisord = self._makeOne(options)
- supervisord.handle_signal()
+ sig = supervisord.handle_signal()
+ self.assertEqual(sig, signal.SIGCHLD)
self.assertEqual(supervisord.options.mood,
SupervisorStates.RUNNING)
# supervisor.options.signame(signal.SIGCHLD) may return "SIGCLD"
@@ -665,6 +667,29 @@ class SupervisordTests(unittest.TestCase):
supervisord.runforever()
self.assertEqual(len(supervisord.ticks), 3)
+ def test_runforever_does_not_reap_without_pids_or_sigchld(self):
+ options = DummyOptions()
+ options.test = True
+ supervisord = self._makeOne(options)
+ supervisord.runforever()
+ self.assertEqual(options.waitpid_calls, 0)
+
+ def test_runforever_reaps_when_tracking_pids(self):
+ options = DummyOptions()
+ options.test = True
+ options.pidhistory = {1: None}
+ supervisord = self._makeOne(options)
+ supervisord.runforever()
+ self.assertEqual(options.waitpid_calls, 1)
+
+ def test_runforever_reaps_when_sigchld_received(self):
+ options = DummyOptions()
+ options.test = True
+ options._signal = signal.SIGCHLD
+ supervisord = self._makeOne(options)
+ supervisord.runforever()
+ self.assertEqual(options.waitpid_calls, 1)
+
def test_runforever_poll_dispatchers(self):
options = DummyOptions()
options.poller.result = [6], [7, 8]