Skip to content

CPython 3.13 Compat and Asyncore Removal #1244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

kheina
Copy link

@kheina kheina commented May 23, 2025

Per Python3.13 Release Notes:

Remove the PyEval_ThreadsInitialized() function, deprecated in Python 3.9. Since Python 3.7, Py_Initialize() always creates the GIL: calling PyEval_InitThreads() does nothing and PyEval_ThreadsInitialized() always returns non-zero. (Contributed by Victor Stinner in gh-105182.)

Removes the use of PyEval_ThreadsInitialized() and PyEval_InitThreads() if python version is >= 3.7 (written by @daskol in 27969fc)

Additionally, removes existing references to asyncore in cassandra/cluster.py tests/integration/long/test_ipv6.py tests/unit/io/test_asyncioreactor.py (per @medaminezghal in #1242 (comment)

@absurdfarce
Copy link
Collaborator

Thanks for the PR @kheina!

Have you signed the Contributor License Agreement for contributions to DataStax open source projects? If not you can find it at https://cla.datastax.com/. Thanks!

Regarding your change specifically: the Python driver aims to support all Python runtimes that aren't end-of-life (EOL) at the time of the drivers release. As of this writing Python 3.9 through Python 3.13 are all not end-of-life, and since asyncore was only removed in Python 3.12 that means any future release would still need to support Python runtimes with asyncore available. So we definitely do not want to remove asyncore support from the driver at the moment.

The asyncore reactor is quite stable by this point while the asyncio reactor is somewhat less so. One of the goals for a future 3.30.0 release is to stabilize the asyncio reactor so that it can become the default reactor in future updates. Keep an eye on PYTHON-1375 for more information on that point.

Great catch on the PyEval_* functions... I need to review some of those generally to see how we're doing with supported Python versions.

I've been distracted by other work recently and haven't had much time to put into working on the next Python release. I'm hoping that changes soon but we'll see how that goes.

@kheina
Copy link
Author

kheina commented May 29, 2025

I have now signed the cla. regarding f34001b, I made those changes as it seemed like that was blocking these changes being merged, but the only required change for python 3.13 (at least for me to compile it locally) was 27969fc. it is worth noting that asyncore no longer exists as of python 3.12

@absurdfarce
Copy link
Collaborator

Hey @kheina, it looks like the thread initialization changes in this PR are replicated in #1242 and the asyncore-to-asyncio changes aren't something I'd like to do (for reasons discussed above). As a result I'm going to close this PR out; we'll continue the discussion around the thread initialization logic in #1242. Please join in there!

And thanks again for putting this PR together!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants