CASSANDRA-20997: Support Python 3.12 and 3.13 in cqlsh#4628
CASSANDRA-20997: Support Python 3.12 and 3.13 in cqlsh#4628arvindKandpal-ksolves wants to merge 1 commit intoapache:trunkfrom
Conversation
maurerle
left a comment
There was a problem hiding this comment.
This looks good!
I did not find the location where asyncore is needed though. Can you point me to it please?
Would it be an option to migrate this to asyncio - as the replacement for asyncore - in the midterm?
The pyasyncore dependency is only needed for python>=3.12. Older versions should not complain though:
The module can be installed for earlier Python versions, but it will have no effect, and the standard library version of asyncore will be used in its place.
|
Hi @maurerle, thanks for the review! To answer your questions:
|
|
@arvindKandpal-ksolves - there is already an AsyncioReactor experimental available (due to limited asyncio support in ancient python versions (3.4, 3.5). I somehow could not build and test the asyncio reactor here, as I did not get the test setup running. |
|
Hi @maurerle, You raise a very valid concern. The "experimental" docstring in that file seems to be a relic from the Python 3.4/3.5 era (as the comments mention 3.4.6/3.5.1 compatibility). While the underlying Since I haven't thoroughly tested how Because of this unknown risk, I think vendoring I'd be happy to open a follow-up JIRA ticket to properly configure, benchmark, and test |
|
Yes, LLM, this sounds like a safe path forward. |
😄 I used a bit of AI to help polish my English, but the local testing and digging through the zip files was all manual work! On a serious note, I just see the So it looks like we don't even need a new follow-up ticket. This PR will just act as a bridge until that updated driver is bundled in Cassandra. Let me know if there's anything else you need me to do for this PR! |
Support Python 3.12 and 3.13 in cqlsh by vendoring the pyasyncore package.
Context / Background
Currently, starting
cqlshwith Python 3.12 or 3.13 fails. Even if the version guards are relaxed, it crashes with aDependencyExceptionbecause Python 3.12 removed theasyncoremodule from the standard library (PEP 594). The bundled Datastax python driver (cassandra-driver-internal-only) relies onasyncoreas a default fallback event loop when C-extensions (libev) are not present, causing it to crash at import time.Changes Made
To fix this without modifying the bundled third-party driver's internal code:
.build/build-resolver.xmlto fetch the officialpyasyncorepackage from PyPI and package it as a.zipin thelib/directory.'pyasyncore-'to thethird_partiestuple inbin/cqlsh.pyso it gets injected intosys.pathat runtime (matching the existing approach forwcwidthandpure_sasl).bin/cqlshandbin/cqlsh.pyto allow Python up to 3.13.Testing
ant cqlshto verify thatpyasyncore-1.0.5-py3-none-any.zipis downloaded and copied to thelib/directory.cqlshlocally withCQLSH_PYTHON=python3.12andCQLSH_PYTHON=python3.13to confirm it successfully connects to the cluster without throwing driver import errors.patch by Arvind Kandpal; for CASSANDRA-20997 and CASSANDRA-19206