PrefectHQ
prefect
BlogDocsChangelog

Add in_process mode to prefect_test_harness to avoid VCR/httpcore hangs

#20128
Comparing
fix/test-harness-in-process-mode
(
64f137a
) with
main
(
bcb0fa0
)
CodSpeed Performance Gauge
0%
Untouched
2
Ignored
6

Benchmarks

Passed

bench_task_decorator
benches/bench_tasks.py
CodSpeed Performance Gauge
0%
601 µs601.3 µs
bench_import_prefect_flow
benches/bench_import.py
CodSpeed Performance Gauge
0%
1.4 s1.4 s

Ignored

bench_flow_call[options0]
benches/bench_flows.py
Ignored
CodSpeed Performance Gauge
-1%
171.3 ms172.3 ms
bench_flow_decorator
benches/bench_flows.py
Ignored
CodSpeed Performance Gauge
+11%
5.7 ms5.1 ms
bench_flow_call[options1]
benches/bench_flows.py
Ignored
CodSpeed Performance Gauge
-1%
106.4 ms107.6 ms
bench_task_submit
benches/bench_tasks.py
Ignored
CodSpeed Performance Gauge
-14%
9.1 ms10.7 ms
bench_import_prefect
benches/bench_import.py
Ignored
CodSpeed Performance Gauge
0%
1.1 s1.1 s
bench_task_call
benches/bench_tasks.py
Ignored
CodSpeed Performance Gauge
+2%
31.6 ms31.2 ms

Commits

Click on a commit to change the comparison range
Base
main
bcb0fa0
-0.05%
Add in_process mode to prefect_test_harness to avoid VCR/httpcore hangs When using prefect_test_harness with HTTP mocking libraries like VCR/vcrpy, nested subflows can hang due to httpcore.PoolTimeout. This happens because VCR wraps httpcore's connection handling and doesn't properly release connections between subflows. This adds an `in_process=True` option that runs the Prefect server in-process using ASGI transport instead of starting a subprocess HTTP server. This completely bypasses HTTP connection pooling, avoiding the VCR issue. Historical context: The subprocess server was introduced in PR #14722 to support WebSockets (required for events). The in-memory ASGI approach doesn't support WebSockets, so this new option is opt-in for backwards compatibility. The implementation uses a ContextVar to avoid backwards imports - testing utilities import from client code, not vice versa. Fixes: pydantic/pydantic-ai#3929 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
64f137a
2 days ago
by zzstoatzz
© 2026 CodSpeed Technology
Home Terms Privacy Docs