GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add Python 3.14 support, experimental subinterpreter/freethreading support by elprans · Pull Request #1279 · MagicStack/asyncpg

Conversation

@elprans

@elprans elprans commented Oct 13, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

The bulk of the changes here is a rewrite of recordobj.c to use modern
CPython API to properly isolate the module (PEP 489, PEP 573, PEP 630).
This, along with Cython flags, enables support for safely importing
asyncpg in subinterpreters. The Record freelist is now
thread-specific, so asyncpg should be thread-safe at the C level.
Support for subinterpreters and freethreading is EXPERIMENTAL.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

kamikaze, horpto, CHC383, antonmyronyuk, and awoimbee reacted with thumbs up emoji
All reactions
  • 👍 5 reactions
@elprans
elprans force-pushed the py314 branch from 66b21e8 to e2427b2 Compare October 13, 2025 21:20
@ddanier

ddanier commented Oct 14, 2025

Copy link
Copy Markdown

As of no pre-built package being available for asyncpg on Python 3.14 you cannot install the package on "slim" docker images, cause gcc is not installed there. This is an issue as you tend to use those "slim" variants when you care about security. Of course it is possible to get this working by either compiling this package yourself on a non-"slim" image and then use a multistage build or switching to the non-"slim" version, but that either does increase complexity or reduce security significantly.

What I want to say: I really would like this to get finished and merged soon. Thanks for all the effort! ;-)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@elprans
elprans force-pushed the py314 branch from e2427b2 to f21c7d4 Compare October 16, 2025 18:49
@elprans elprans changed the title Add Python 3.14 support, drop EOL 3.8 Add Python 3.14 support, experimental subinterpreter/freethreading support Oct 16, 2025
@elprans
elprans force-pushed the py314 branch from f21c7d4 to 43a61ef Compare October 16, 2025 18:50
@elprans
elprans requested review from 1st1 and fantix October 16, 2025 18:51
@elprans
elprans force-pushed the py314 branch 2 times, most recently from e742ff7 to 7037527 Compare October 16, 2025 18:53
@elprans
elprans requested a review from msullivan October 16, 2025 18:54
@elprans
elprans force-pushed the py314 branch from 7037527 to d8a2587 Compare October 16, 2025 19:52
fantix
fantix reviewed Oct 16, 2025
View reviewed changes
Comment thread asyncpg/record/recordobj.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread .github/workflows/tests.yml Resolved

Uh oh!

There was an error while loading. Please reload this page.

@elprans
elprans force-pushed the py314 branch 3 times, most recently from 483125b to fd6d675 Compare October 17, 2025 04:36
@elprans
elprans requested a review from fantix October 17, 2025 04:57
@frankie567 frankie567 mentioned this pull request Oct 18, 2025
Python free-threading support polarsource/polar#7342
Closed
1st1
1st1 reviewed Oct 20, 2025
View reviewed changes
Comment thread asyncpg/protocol/codecs/base.pyx Resolved

Uh oh!

There was an error while loading. Please reload this page.

1st1
1st1 reviewed Oct 20, 2025
View reviewed changes
Comment thread asyncpg/record/recordobj.c
@@ -0,0 +1,1281 @@
/* Big parts of this file are copied (with modifications) from

@1st1 1st1 Oct 20, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Any reason for this file to be moved? No diff now, all code is like new which makes review harder

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@elprans elprans Oct 20, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

There were some odd Cython issues initially, but I'll see if I can move it back.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@elprans elprans Oct 20, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Done, @1st1, please take another look.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
1st1
1st1 reviewed Oct 20, 2025
View reviewed changes

@1st1 1st1 left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Can we move recordobj.c back where it was?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@elprans

elprans commented Oct 20, 2025

Copy link
Copy Markdown
Member Author

Can we move recordobj.c back where it was?

I couldn't find a way to do it. Cython does not expose a way to plug into its generated module state, so record must be a standalone module, not a concatenation. Why is this important?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@1st1

1st1 commented Oct 20, 2025

Copy link
Copy Markdown
Member

I couldn't find a way to do it. Cython does not expose a way to plug into its generated module state, so record must be a standalone module, not a concatenation. Why is this important?

Just for me to review the thing, it's a big file. Were there any changes in it?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@elprans
elprans force-pushed the py314 branch from fd6d675 to 393f8a2 Compare October 20, 2025 16:55
@elprans
elprans requested a review from 1st1 October 20, 2025 16:55
@elprans
elprans force-pushed the py314 branch 2 times, most recently from f5bb6f8 to 8eed349 Compare October 20, 2025 17:16
@elprans
Add Python 3.14 support, experimental subinterpreter/freethreading su…
ecb4c19
…pport

The bulk of the changes here is a rewrite of `recordobj.c` to use modern
CPython API to properly isolate the module (PEP 489, PEP 573, PEP 630).
This, along with Cython flags, enables support for safely importing
`asyncpg` in subinterpreters.  The `Record` freelist is now
thread-specific, so asyncpg should be thread-safe *at the C level*.
Support for subinterpreters and freethreading is EXPERIMENTAL.
@elprans
elprans force-pushed the py314 branch from 8eed349 to ecb4c19 Compare October 20, 2025 19:01
1st1
1st1 reviewed Oct 20, 2025
View reviewed changes
Comment thread asyncpg/protocol/record/recordobj.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

1st1
1st1 reviewed Oct 20, 2025
View reviewed changes
Comment thread asyncpg/protocol/record/recordobj.c
v_is_tuple = 1;
}
else if (ApgRecord_CheckExact(v)) {
else if (v_type == state->ApgRecord_Type) {

@1st1 1st1 Oct 20, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I'd keep the ApgRecord_CheckExact macros, just make it accept state as first arg.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
1st1
1st1 reviewed Oct 20, 2025
View reviewed changes
Comment thread asyncpg/protocol/record/recordobj.c Outdated
cmp = vlen >= wlen;
break;
default:
return NULL; /* cannot happen */

@1st1 1st1 Oct 20, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Py_UNREACHABLE();

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
1st1
1st1 reviewed Oct 20, 2025
View reviewed changes
Comment thread tests/test_subinterpreters.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

1st1
1st1 approved these changes Oct 20, 2025
View reviewed changes

@1st1 1st1 left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

looks ok but please run tests in refleak hunt mode

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
msullivan
msullivan approved these changes Oct 20, 2025
View reviewed changes
Comment thread asyncpg/protocol/record/recordobj.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

elprans added 4 commits October 20, 2025 15:12
@elprans
Decref heap types
7775923
@elprans
Drop iterable_coroutine
24e8a53
@elprans
Enhance subinterpreter tests
5322b9d
@elprans
nit
63a2c33
@elprans
elprans merged commit 9e42642 into master Oct 21, 2025
@elprans
elprans deleted the py314 branch October 21, 2025 19:20
@bfontaine bfontaine mentioned this pull request Nov 17, 2025
Support for Python 3.14 Free Threading (no GIL) #1287
Closed
@bfontaine

bfontaine commented Nov 21, 2025

Copy link
Copy Markdown

When is this expected to be released?

jgallego-steeldevelop and jackien1 reacted with eyes emoji
All reactions
  • 👀 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

elprans added a commit that referenced this pull request Nov 24, 2025
@elprans
asyncpg v0.31.0
71775a6
Enable Python 3.14 with experimental subinterpreter/freethreading
support.

Improvements
============

* Add Python 3.14 support, experimental subinterpreter/freethreading support (#1279)
  (by @elprans in 9e42642)

* Avoid performing type introspection on known types (#1243)
  (by @elprans in 5c9986c)

* Make `prepare()` not use named statements by default when cache is disabled (#1245)
  (by @elprans in 5b14653)

* Implement connection service file functionality (#1223)
  (by @AndrewJackson2020 in 1d63bb1)

Fixes
=====

* Fix multi port connection string issue (#1222)
  (by @AndrewJackson2020 in 01c0db7)

* Avoid leaking connections if _can_use_connection fails (#1269)
  (by @yuliy-openai in e94302d)

Other
=====

* Drop support for EOL Python 3.8 (#1281)
  (by @elprans in 6c2c490)
@elprans elprans mentioned this pull request Nov 24, 2025
asyncpg v0.31.0 #1291
Merged
bg-admin7 pushed a commit to bg-open-source/asyncpg that referenced this pull request Dec 10, 2025
Andrei K
Merge tag 'v0.31.0' into non-blocking-conns-v3
acc3154
asyncpg v0.31.0

Enable Python 3.14 with experimental subinterpreter/freethreading
support.

Improvements
============

* Add Python 3.14 support, experimental subinterpreter/freethreading support (MagicStack#1279)
  (by @elprans in 9e42642)

* Avoid performing type introspection on known types (MagicStack#1243)
  (by @elprans in 5c9986c)

* Make `prepare()` not use named statements by default when cache is disabled (MagicStack#1245)
  (by @elprans in 5b14653)

* Implement connection service file functionality (MagicStack#1223)
  (by @AndrewJackson2020 in 1d63bb1)

Fixes
=====

* Fix multi port connection string issue (MagicStack#1222)
  (by @AndrewJackson2020 in 01c0db7)

* Avoid leaking connections if _can_use_connection fails (MagicStack#1269)
  (by @yuliy-openai in e94302d)

Other
=====

* Drop support for EOL Python 3.8 (MagicStack#1281)
  (by @elprans in 6c2c490)

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEES/rQWfT9RAppNY3YXEaHeAYth78FAmkk6UMACgkQXEaHeAYt
# h7+LBw//fX/3/nHrEUctYR7A/WQqg2oj3nvk10b3OQjzHUGyHq0DhkSC7/H9P0FI
# vl0j2n+BfKcKxOw4OgbxDq5fff/a4ScsejVwsKqQEEDH9tiXAL2cIId1yvNWC9hJ
# 8WxmkJzbFHdrl1D3/pxUv15UoaMSZD1DtPXaYEupRyEKXVOfQ/ush5GU5M3vA19R
# aWrAFtbMd3MMfaBYEO1TQtZNCV3n3Dv8fmIwv8qPbqJt2lsk4HOE8F3Be/RGiaPZ
# dI9eGnZ+qmlYC/mZYKNywaBlm4v/hHhuGwSh8WdkY6h4lFkBl8HipuPpoNeWO/fd
# k5wl1Q2HA8i2qEokz7EzYPRYjOPZwXphxscRXJQbdlCNyfJ+lPTu3uAQ08RTnoGU
# +JROauwgtQknnZEGtRWNerRcbZE1D+SgkLhGkEk6+tcIJ0G2XoCsn7A/u9LMmZuN
# 7lcFnLEdDnUSaLx7SZgcbOKP1Acg1W2Vk375JxXrymGqq5FPss8cdg+KOFMNuljT
# v/RtKvAP3yXpR448uPQ6M4BNVJ5my3UwdPrHwpGNkSxaqKBGGtryBG4LLw43yPCg
# FPFO9P//z+59RsmAvilaOhT/pLhqRvOJTkaUt5bt6Fw+5SzCfNfciNkl4rBC+9EQ
# LC/NQmO9cFYlpnO7s3uF0M+JTLV1u0CJp5G5USiQiEU+tVlaH6E=
# =bEvL
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue 25 Nov 2025 12:24:51 AM CET
# gpg:                using RSA key 4BFAD059F4FD440A69358DD85C468778062D87BF
# gpg: Can't check signature: No public key
bg-admin7 pushed a commit to bg-open-source/asyncpg that referenced this pull request Dec 10, 2025
Andrei K
Merge tag 'v0.31.0' into non-blocking-conns-v4
64ddc43
asyncpg v0.31.0

Enable Python 3.14 with experimental subinterpreter/freethreading
support.

Improvements
============

* Add Python 3.14 support, experimental subinterpreter/freethreading support (MagicStack#1279)
  (by @elprans in 9e42642)

* Avoid performing type introspection on known types (MagicStack#1243)
  (by @elprans in 5c9986c)

* Make `prepare()` not use named statements by default when cache is disabled (MagicStack#1245)
  (by @elprans in 5b14653)

* Implement connection service file functionality (MagicStack#1223)
  (by @AndrewJackson2020 in 1d63bb1)

Fixes
=====

* Fix multi port connection string issue (MagicStack#1222)
  (by @AndrewJackson2020 in 01c0db7)

* Avoid leaking connections if _can_use_connection fails (MagicStack#1269)
  (by @yuliy-openai in e94302d)

Other
=====

* Drop support for EOL Python 3.8 (MagicStack#1281)
  (by @elprans in 6c2c490)

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEES/rQWfT9RAppNY3YXEaHeAYth78FAmkk6UMACgkQXEaHeAYt
# h7+LBw//fX/3/nHrEUctYR7A/WQqg2oj3nvk10b3OQjzHUGyHq0DhkSC7/H9P0FI
# vl0j2n+BfKcKxOw4OgbxDq5fff/a4ScsejVwsKqQEEDH9tiXAL2cIId1yvNWC9hJ
# 8WxmkJzbFHdrl1D3/pxUv15UoaMSZD1DtPXaYEupRyEKXVOfQ/ush5GU5M3vA19R
# aWrAFtbMd3MMfaBYEO1TQtZNCV3n3Dv8fmIwv8qPbqJt2lsk4HOE8F3Be/RGiaPZ
# dI9eGnZ+qmlYC/mZYKNywaBlm4v/hHhuGwSh8WdkY6h4lFkBl8HipuPpoNeWO/fd
# k5wl1Q2HA8i2qEokz7EzYPRYjOPZwXphxscRXJQbdlCNyfJ+lPTu3uAQ08RTnoGU
# +JROauwgtQknnZEGtRWNerRcbZE1D+SgkLhGkEk6+tcIJ0G2XoCsn7A/u9LMmZuN
# 7lcFnLEdDnUSaLx7SZgcbOKP1Acg1W2Vk375JxXrymGqq5FPss8cdg+KOFMNuljT
# v/RtKvAP3yXpR448uPQ6M4BNVJ5my3UwdPrHwpGNkSxaqKBGGtryBG4LLw43yPCg
# FPFO9P//z+59RsmAvilaOhT/pLhqRvOJTkaUt5bt6Fw+5SzCfNfciNkl4rBC+9EQ
# LC/NQmO9cFYlpnO7s3uF0M+JTLV1u0CJp5G5USiQiEU+tVlaH6E=
# =bEvL
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue 25 Nov 2025 12:24:51 AM CET
# gpg:                using RSA key 4BFAD059F4FD440A69358DD85C468778062D87BF
# gpg: Can't check signature: No public key
@kb1ibt kb1ibt mentioned this pull request Jul 6, 2026
Segmentation fault on 0.31.0 when inside a Temporal activity #1292
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@1st1 1st1 1st1 approved these changes
@msullivan msullivan msullivan approved these changes
@fantix fantix Awaiting requested review from fantix

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@elprans @ddanier @1st1 @bfontaine @msullivan @fantix
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.