Skip to content

test: wait on ExecProcess after expected TypeError#2509

Merged
tonyandrewmeyer merged 4 commits into
canonical:mainfrom
tonyandrewmeyer:test-pebble-exec-no-stdout-wait
May 28, 2026
Merged

test: wait on ExecProcess after expected TypeError#2509
tonyandrewmeyer merged 4 commits into
canonical:mainfrom
tonyandrewmeyer:test-pebble-exec-no-stdout-wait

Conversation

@tonyandrewmeyer
Copy link
Copy Markdown
Collaborator

@tonyandrewmeyer tonyandrewmeyer commented May 26, 2026

test_wait_output_no_stdout provokes a TypeError from wait_output() without subsequently waiting on the process, so the ExecProcess is GC'd without _waited being set and ExecProcess.__del__ emits:

ResourceWarning: ExecProcess instance garbage collected without call to wait() or wait_output()

Under -W error that fails the test.

The makes a small (tiny!) change to call process.wait() after the expected TypeError so the leak detector doesn't fire on a test that's intentionally exercising a misuse-error path.

Context: surfaced while making operator's test suite pass under -W error.

`test_wait_output_no_stdout` provokes a TypeError from `wait_output()`
without subsequently waiting on the process, so the ExecProcess is GC'd
without `_waited` being set and `ExecProcess.__del__` emits
`ResourceWarning: ExecProcess instance garbage collected without call to
wait() or wait_output()`. Under `-W error` that fails the test.

Call `process.wait()` after the expected TypeError so the leak detector
doesn't fire on a test that's exercising a misuse-error path.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@tonyandrewmeyer tonyandrewmeyer marked this pull request as draft May 26, 2026 22:25
@tonyandrewmeyer tonyandrewmeyer changed the title test(pebble): wait on ExecProcess after expected TypeError test: wait on ExecProcess after expected TypeError May 26, 2026
If `ExecProcess._wait()` calls `cancel_stdin()` before the
`_reader_to_websocket` thread has been scheduled, `select()` reports
both the cancel pipe and the stdin reader as ready. The old check broke
the loop on cancel without reading, so any pending stdin was dropped
and only the `{"command":"end"}` frame was sent. Python 3.14's thread
scheduling made this race deterministic, failing
`TestExec.test_wait_file_io`.

Break only when the reader is not also ready; when both are ready,
drain the reader first and exit on the next iteration via EOF or a
plain cancel.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@dwilding dwilding left a comment

Choose a reason for hiding this comment

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

I can't confidently review the pebble.py change, as I'm not so familiar with threading - but I get the point of the change. I also get the point of the update to the test. And I checked that we already have a test test_no_wait_call that covers the ResourceWarning.

@tonyandrewmeyer tonyandrewmeyer marked this pull request as ready for review May 27, 2026 23:35
@tonyandrewmeyer tonyandrewmeyer merged commit b985d4d into canonical:main May 28, 2026
59 checks passed
@tonyandrewmeyer tonyandrewmeyer deleted the test-pebble-exec-no-stdout-wait branch May 28, 2026 01:27
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.

3 participants