Skip to content

[3.14 backport] Fix test_data_file race condition on Python 3.14 free-threaded#12172

Merged
Dreamsorcerer merged 1 commit intoaio-libs:3.14from
rodrigobnogueira:patchback/backports/3.14/2d03bc45722f4153c2a993f084ecac04023d54c4/pr-12170
Feb 28, 2026
Merged

[3.14 backport] Fix test_data_file race condition on Python 3.14 free-threaded#12172
Dreamsorcerer merged 1 commit intoaio-libs:3.14from
rodrigobnogueira:patchback/backports/3.14/2d03bc45722f4153c2a993f084ecac04023d54c4/pr-12170

Conversation

@rodrigobnogueira
Copy link
Member

What do these changes do?

Backport of #12170 to the 3.14 release branch.

This fixes a flaky test (test_data_file) that fails on Python 3.14 free-threaded (3.14t) builds.

The test asserts asyncio.isfuture(req._writer) immediately after await req.send(conn). On Python 3.12+, asyncio.Task accepts eager_start=True. Because the 2-byte file payload in the test is tiny, the task may complete synchronously during send(), leaving req._writer as None.

We mock write_bytes to execute await asyncio.sleep(0), guaranteeing the task yields before the assertion.

Are there changes in behavior for the user?

No user-facing changes. This strictly fixes test flakiness.

Is it a substantial burden for the maintainers to support this?

No. This follows the exact same pattern already used in test_data_stream.

Related issue number

Backport of #12170

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes
  • Add a new news fragment into the CHANGES/ folder

@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Feb 28, 2026
@codecov
Copy link

codecov bot commented Feb 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.26%. Comparing base (31d45fd) to head (faf5c67).
⚠️ Report is 1 commits behind head on 3.14.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             3.14   #12172   +/-   ##
=======================================
  Coverage   98.25%   98.26%           
=======================================
  Files         129      129           
  Lines       45678    45683    +5     
  Branches     2473     2473           
=======================================
+ Hits        44881    44890    +9     
+ Misses        615      612    -3     
+ Partials      182      181    -1     
Flag Coverage Δ
CI-GHA 98.14% <100.00%> (+<0.01%) ⬆️
OS-Linux 97.89% <100.00%> (+<0.01%) ⬆️
OS-Windows 95.63% <100.00%> (+<0.01%) ⬆️
OS-macOS 97.16% <100.00%> (-0.01%) ⬇️
Py-3.10.11 96.70% <100.00%> (+<0.01%) ⬆️
Py-3.10.19 97.18% <100.00%> (+<0.01%) ⬆️
Py-3.11.14 97.41% <100.00%> (+<0.01%) ⬆️
Py-3.11.9 96.94% <100.00%> (+<0.01%) ⬆️
Py-3.12.10 97.02% <100.00%> (+<0.01%) ⬆️
Py-3.12.12 97.50% <100.00%> (+<0.01%) ⬆️
Py-3.13.12 97.73% <100.00%> (+<0.01%) ⬆️
Py-3.14.3 97.69% <100.00%> (+<0.01%) ⬆️
Py-3.14.3t 96.79% <100.00%> (-0.01%) ⬇️
Py-pypy3.11.13-7.3.20 96.82% <100.00%> (-0.01%) ⬇️
VM-macos 97.16% <100.00%> (-0.01%) ⬇️
VM-ubuntu 97.89% <100.00%> (+<0.01%) ⬆️
VM-windows 95.63% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 28, 2026

Merging this PR will not alter performance

✅ 59 untouched benchmarks


Comparing rodrigobnogueira:patchback/backports/3.14/2d03bc45722f4153c2a993f084ecac04023d54c4/pr-12170 (faf5c67) with 3.14 (31d45fd)

Open in CodSpeed

@Dreamsorcerer Dreamsorcerer merged commit 0ec5ba4 into aio-libs:3.14 Feb 28, 2026
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided There is a change note present in this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants