Skip to content

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

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

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

Conversation

@rodrigobnogueira
Copy link
Member

What do these changes do?

Backport of #12170 to the 3.13 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
@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.13/2d03bc45722f4153c2a993f084ecac04023d54c4/pr-12170 (00ab8e4) with 3.13 (ed00ce2)

Open in CodSpeed

@Dreamsorcerer
Copy link
Member

Dreamsorcerer commented Feb 28, 2026

It really doesn't want to checkout the repo...

@codecov
Copy link

codecov bot commented Feb 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.28%. Comparing base (ed00ce2) to head (00ab8e4).
⚠️ Report is 1 commits behind head on 3.13.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             3.13   #12171   +/-   ##
=======================================
  Coverage   98.28%   98.28%           
=======================================
  Files         128      128           
  Lines       44699    44704    +5     
  Branches     2431     2431           
=======================================
+ Hits        43932    43939    +7     
+ Misses        590      589    -1     
+ Partials      177      176    -1     
Flag Coverage Δ
CI-GHA 98.17% <100.00%> (+<0.01%) ⬆️
OS-Linux 97.92% <100.00%> (+<0.01%) ⬆️
OS-Windows 95.61% <100.00%> (+<0.01%) ⬆️
OS-macOS 97.17% <100.00%> (+<0.01%) ⬆️
Py-3.10.11 96.72% <100.00%> (+<0.01%) ⬆️
Py-3.10.19 97.19% <100.00%> (+<0.01%) ⬆️
Py-3.11.14 97.38% <100.00%> (+<0.01%) ⬆️
Py-3.11.9 96.91% <100.00%> (+<0.01%) ⬆️
Py-3.12.10 96.99% <100.00%> (+<0.01%) ⬆️
Py-3.12.12 97.48% <100.00%> (+<0.01%) ⬆️
Py-3.13.12 97.70% <100.00%> (+<0.01%) ⬆️
Py-3.14.3 97.62% <100.00%> (+<0.01%) ⬆️
Py-3.14.3t 96.72% <100.00%> (-0.01%) ⬇️
Py-3.9.13 96.60% <100.00%> (+<0.01%) ⬆️
Py-3.9.25 97.08% <100.00%> (-0.01%) ⬇️
Py-pypy3.11.13-7.3.20 96.79% <100.00%> (+<0.01%) ⬆️
VM-macos 97.17% <100.00%> (+<0.01%) ⬆️
VM-ubuntu 97.92% <100.00%> (+<0.01%) ⬆️
VM-windows 95.61% <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.

@Dreamsorcerer Dreamsorcerer merged commit d5cd872 into aio-libs:3.13 Feb 28, 2026
57 of 112 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