Skip to content

Check server errors when a request context exits - #519

Merged
csernazs merged 1 commit into
csernazs:masterfrom
sricharanreddycheruku:agent2-check-requests-on-context-exit
Oct 8, 2026
Merged

csernazs merged 1 commit into
csernazs:masterfrom
sricharanreddycheruku:agent2-check-requests-on-context-exit

Conversation

@sricharanreddycheruku

Copy link
Copy Markdown
Contributor

wait() stops when its first stopping condition is met, so unexpected requests sent after all ordered requests complete are not reported by that context. As proposed in #482, this adds with_check() to run the existing server checks when a block exits normally.

The helper reports unexpected requests and response-handler errors without changing wait() semantics. It yields the server instance and preserves exceptions raised inside the block. It does not wait for requests or stop the server. The how-to documentation and a Reno release note describe these semantics.

Four regression tests cover successful ordered requests, an unexpected request after the expected requests, handler errors, and preservation of a client-side exception. All four fail on the original source because the helper is absent; all pass with this change.

Validation on Linux with Python 3.12.14 and the locked development dependencies installed using Poetry 2.1.1:

  • HTTP suite including release/package tests: pytest -q tests --release — 154 passed, 3 skipped, 2 xfailed; the existing tar-extraction warning remains.
  • Existing HTTPS suite: pytest -q tests --ssl — 1 passed, 158 skipped by the SSL selection.
  • Handler-error and wait tests: 13 passed.
  • Mypy: no issues in 57 source files.
  • make precommit and git diff --check: passed.
  • make doc: passed. Its 59 warnings also occur with unchanged source; this change introduces none.

Fixes #482

@csernazs

csernazs commented Oct 8, 2026

Copy link
Copy Markdown
Owner

Hi @sricharanreddycheruku,

Thanks for your PR, it looks good and I'll merge it now.

Since I had a release a couple of days ago, is it ok for you to wait a few days for the next release? Until then you can give it a try by referencing to the master branch of this repository.

Thanks,
Zsolt

@csernazs
csernazs merged commit 7c6b723 into csernazs:master Oct 8, 2026
10 checks passed
@sricharanreddycheruku
sricharanreddycheruku deleted the agent2-check-requests-on-context-exit branch October 8, 2026 14:06
@sricharanreddycheruku

Copy link
Copy Markdown
Contributor Author

Thanks, Yes, waiting a few days for the next release is fine. Thanks for reviewing and merging the PR.

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.

wait with stop_on_nohandler=True does not raise exceptions on unexpected reqs after expected ones

2 participants