Fix race on free-threaded: read _expire_at only once

MS
4mo ago
+24-4

Closes #1027

Summary

Running on 3.14t, we sometimes run into a small race where on that line, the first read of _expire_at and the second diverge. This PR is definitely not bringing full compatibility with 3.14t, but it's a small race fix that will benefit https://github.com/encode/httpcore/pull/1042

Seems like someone else ran into it and reported it: https://github.com/encode/httpcore/discussions/1027

Given the small scope of the change, I only ticked the first checklist item below.

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.