Skip to content

Remove unreachable Windows process termination - #1511

Open
agustin18 wants to merge 2 commits into
dbfixtures:mainfrom
agustin18:remove-unreachable-windows-termination
Open

agustin18 wants to merge 2 commits into
dbfixtures:mainfrom
agustin18:remove-unreachable-windows-termination

Conversation

@agustin18

@agustin18 agustin18 commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1504.

On Windows, start() runs pg_ctl start synchronously and returns without calling super().start(), so self.process is never set. That made the rest of the Windows stop path dead code:

  • _windows_terminate_process() always returned at if self.process is None.
  • self._process = None set an attribute nothing reads; mirakuru keeps the process in self.process and clears it through _clear_process().
  • The except AttributeError fallback could not run: the branch above it handles Windows, and os.killpg exists on every non-Windows platform.

stop() now runs pg_ctl stop and, off Windows, delegates to super().stop() as before. The helper, both _process assignments, the fallback and the tests that covered them are gone.

Testing

  • tests/test_windows_compatibility.py -> 38 passed. test_stop_method_windows now asserts that only pg_ctl stop runs, that super().stop() is not called, and that no _process attribute is created.
  • Full suite: 14 failed, 169 passed, 76 errors locally, all from a missing pg_ctl/pg_config in this environment. The same 14 failures and 76 errors occur on the base commit; the only difference is the three tests removed here.
  • ruff check and ruff format --check pass.

Summary by CodeRabbit

  • Bug Fixes
    • PostgreSQL shutdown on Windows now uses the same PostgreSQL control command used on other platforms, rather than separately terminating the launcher process.
    • Shutdown timeouts are now reported as timeout errors.
    • On non-Windows platforms, the additional connection shutdown step is retained.

`start()` runs `pg_ctl start` synchronously on Windows, so `self.process`
is never set: `_windows_terminate_process()` returned early, `_process`
was never read, and the `AttributeError` fallback could not run because
`os.killpg` exists on every non-Windows platform.

Drop the helper, the assignments, the fallback and the tests that cover
them. On Windows `stop()` is now just `pg_ctl stop`.

Closes dbfixtures#1504
@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The Windows-specific termination helper and fallback logic were removed. stop() issues pg_ctl stop on all platforms. It calls TCPExecutor.stop() only on non-Windows and ignores ProcessFinishedWithError. Windows tests now check this behaviour.

Changes: Executor stop behaviour

Layer / File(s) Summary
Stop behaviour and regression tests
pytest_postgresql/executors/proc.py, tests/test_windows_compatibility.py, newsfragments/1504.misc.rst
stop() now calls TCPExecutor.stop() only on non-Windows and ignores ProcessFinishedWithError. The Windows termination helper, process-reference reset and AttributeError fallback were removed. Windows tests check that stop() invokes pg_ctl stop and does not call TCPExecutor.stop(). The news fragment records the removal.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Suggested reviewers: tboy1337, fizyk

Merge Risk: Minimal · previous review 59bee

This cleanup removes dead Windows-only stop code and keeps the pg_ctl stop behavior. No user-visible regression is expected, and it is ready to merge.

Pre-merge checks: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Linked Issues check Inconclusive [#1504] Requirements: remove _windows_terminate_process, the _process assignments, the AttributeError fallback and their tests, so that Windows stop() runs pg_ctl stop alone, with non-Window… Provide readable source for pytest_postgresql/executors/proc.py stop() at the reviewed head (or a diff against the merge base that the tooling can render). Confirm that the Windows branch of stop() runs only pg_ctl stop, that no `_p…
Passed Passed checks: 4 passed

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "Remove unreachable Windows process termination" matches the main change. The PR removes the Windows process-termination helper, the _process assignments, and the AttributeError fallback fro…
Out of Scope Changes check Passed The described changes all relate to #1504: the news fragment newsfragments/1504.misc.rst, the removal of the Windows termination helper and related _process handling in proc.py, and the removal …
Newsfragment Check Passed The PR adds a newsfragment, so the check passes. - The reviewed diff adds newsfragments/1504.misc.rst (status A). It also modifies pytest_postgresql/executors/proc.py and `tests/test_windows_com…
Full details: Title check

Explanation

The title "Remove unreachable Windows process termination" matches the main change. The PR removes the Windows process-termination helper, the _process assignments, and the AttributeError fallback from PostgreSQLExecutor.stop, and it removes tests for them. The title is short, specific, and uses no vague terms.

Full details: Out of Scope Changes check

Explanation

The described changes all relate to #1504: the news fragment newsfragments/1504.misc.rst, the removal of the Windows termination helper and related _process handling in proc.py, and the removal and replacement of the related tests in tests/test_windows_compatibility.py. The visible code at head (start(), check_subprocess(), wait_for_postgres(), init_directory()) contains no unrelated functional change. The stop() body was not fully readable, so the statement that stop() now uses -m f and timeout translation is not confirmed as pre-existing. No concrete unrelated change was demonstrated.

Full details: Newsfragment Check

Explanation

The PR adds a newsfragment, so the check passes. - The reviewed diff adds newsfragments/1504.misc.rst (status A). It also modifies pytest_postgresql/executors/proc.py and tests/test_windows_compatibility.py. - The filename follows the [issue_number].[type].rst format. The issue number 1504 matches linked issue #1504. - The type misc is valid. pyproject.toml defines misc as a [[tool.towncrier.type]] entry (name "Miscellaneous"). - The fragment content is one sentence: "Remove the unreachable Windows process termination from PostgreSQLExecutor.stop(); pg_ctl stop already does the work." It describes the change. - The newsfragments/ directory at head contains other fragments with the same naming pattern, so the convention matches. No remediation is needed.

Full details: Linked Issues check

Explanation

[#1504] Requirements: remove _windows_terminate_process, the _process assignments, the AttributeError fallback and their tests, so that Windows stop() runs pg_ctl stop alone, with non-Windows behaviour unchanged. At head, start() and check_subprocess() in pytest_postgresql/executors/proc.py contain no Windows termination helper and no _process reference. The Windows start() branch returns without calling super().start(), which matches the issue's premise. However, the stop() body (after the first pg_ctl stop call) was truncated in the read, and the repository diff could not be read because changed blobs were unavailable. Therefore the stop body, the removal of the fallback and the ProcessFinishedWithError handling on non-Windows could not be verified from source. The test file tests/test_windows_compatibility.py could not be inspected either. The PR description and the AI-generated summary describe the intended change, but they are not source evidence.

Resolution

Provide readable source for pytest_postgresql/executors/proc.py stop() at the reviewed head (or a diff against the merge base that the tooling can render). Confirm that the Windows branch of stop() runs only pg_ctl stop, that no _process or _windows_terminate_process reference remains, and that the non-Windows path still calls super().stop() as before. Also confirm that tests/test_windows_compatibility.py no longer tests the removed helper.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between dcacc20 and 59bee53.

Files selected for processing: 3

  • newsfragments/1504.misc.rst
  • pytest_postgresql/executors/proc.py
  • tests/test_windows_compatibility.py

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@codecov

codecov Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

The moved 'except ProcessFinishedWithError' branch is now reached by a
test that makes super().stop() raise it.
)
mock_terminate.assert_called_once_with(None)
mock_super_stop.assert_not_called()
assert not hasattr(executor, "_process")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

let's not assert for code we dropped, likely it won't be back

This branch has not been deployed

No deployments
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.

Remove unreachable Windows process termination from PostgreSQLExecutor.stop

2 participants