Skip to content

CASSPYTHON-12 Mark eventlet, gevent and Twisted event loops as deprecated#1279

Open
absurdfarce wants to merge 4 commits intoapache:trunkfrom
absurdfarce:casspython12
Open

CASSPYTHON-12 Mark eventlet, gevent and Twisted event loops as deprecated#1279
absurdfarce wants to merge 4 commits intoapache:trunkfrom
absurdfarce:casspython12

Conversation

@absurdfarce
Copy link
Contributor

@absurdfarce absurdfarce commented Mar 10, 2026

Leverage the deprecated Python package to handle most of the heavy lifting here.

Local testing confirms that gevent connections still work and that the deprecation warning is printed as expected:

2026-03-10 16:28:01,976 [DEBUG] cassandra.cluster: [control connection] Opening new connection to 8c86116c-e592-4e28-886f-e22cb44935d3-us-east-2.db.astra.datastax.com:29042:678e6a1d-e5b1-3cba-b949-7bfaf823957f                             
/home/mersault/work/scratch/python-astra/client.py:33: DeprecationWarning: Call to deprecated class GeventConnection. (The gevent event loop is deprecated and will be removed in 3.31.0.  See CASSPYTHON-12.) -- Deprecated since version 3.3
0.0.                                                                                                                                                                                                                                          
  session = cluster.connect() 

@absurdfarce absurdfarce requested a review from bschoening March 10, 2026 21:33
@absurdfarce
Copy link
Contributor Author

Jenkins run looks normal so the deprecation warnings don't seem to interfere with functionality

@bschoening
Copy link
Contributor

bschoening commented Mar 11, 2026

@absurdfarce I noticed pyproject.toml has mismatched versions. Would be good to align those here.

requires-python = ">= 3.10"
classifiers = [
    ...
    "Programming Language :: Python :: 3.9",

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces standardized deprecation warnings for the gevent, eventlet, and Twisted-based connection implementations by using the Deprecated package, and updates the installation docs to reflect the event-loop roadmap.

Changes:

  • Add Deprecated as a runtime dependency.
  • Decorate GeventConnection, EventletConnection, and TwistedConnection with @deprecated(...) to emit DeprecationWarnings.
  • Update documentation for supported event loops and deprecation/removal timelines.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pyproject.toml Adds Deprecated to runtime dependencies to support deprecation decorators.
docs/installation.rst Updates supported event loop guidance and notes deprecation/removal plans.
cassandra/io/geventreactor.py Marks GeventConnection class as deprecated via Deprecated.
cassandra/io/eventletreactor.py Marks EventletConnection class as deprecated via Deprecated.
cassandra/io/twistedreactor.py Marks TwistedConnection class as deprecated via Deprecated.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

pyproject.toml Outdated
description = "Apache Cassandra Python Driver"
version = "3.30.0"
dependencies = ['geomet>=1.1']
dependencies = ['geomet>=1.1', "Deprecated"]
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

Deprecated is added as a new runtime dependency, but it is unversioned while the existing core dependency (geomet>=1.1) uses a lower bound. Please add an explicit version specifier for Deprecated (at least a tested minimum), and ensure the dependency lists used for manual/test installs (e.g., requirements.txt referenced by docs and test-requirements.txt) are kept in sync so from deprecated import deprecated doesn't fail in those workflows.

Suggested change
dependencies = ['geomet>=1.1', "Deprecated"]
dependencies = ['geomet>=1.1', "Deprecated>=1.2.0"]

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, okay. It seems quite unlikely that (a) venvs (or an equivalent) with older versions of deprecated would even wind up being used and (b) even if they were they prolly wouldn't be likely to break things but sure, I guess it doesn't hurt anything.

My testing was done locally with deprecated 1.3.1 so I'm going with that.

available via Python modules or C extensions. Python 3.12 has removed ``asyncore`` entirely
so for this platform one of these other event loops must be used.
The ``asyncore`` and ``libev`` event loops are proven production-grade event loops. Python 3.12 removed
asyncore from the runtime but this event loop can still be used in newer versions of Python via the
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

In this paragraph, asyncore is mentioned without literal formatting while other module names are consistently marked up (e.g., asyncore / libev). For consistency and to avoid Sphinx formatting drift, wrap this asyncore occurrence in double backticks.

Suggested change
asyncore from the runtime but this event loop can still be used in newer versions of Python via the
``asyncore`` from the runtime but this event loop can still be used in newer versions of Python via the

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I disagree with this suggestion for two reasons.

First, I prefer the idea of highlighting the first usage of a name and then leaving all other subsequent usages to be rendered as regular text.

Second (and perhaps more importantly): the second usage refers to the asyncore package in the Python runtime and not the asyncore event loop built on that package. They are two different things and using the same formatting to indicate the would confuse the issue.

@absurdfarce
Copy link
Contributor Author

Good catch on the pyproject.toml mismatch @bschoening. The classifiers weren't updated in general so Python 3.14 also isn't there. I'll have a fix coming momentarily.

…n versions and the

list of versions we included in the classifiers.
description = "Apache Cassandra Python Driver"
version = "3.30.0"
dependencies = ['geomet>=1.1']
dependencies = ['geomet>=1.1', "Deprecated>=1.3.1"]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Worth noting that this dependency will only be present for this release. The plan is to remove the event loops in question in the next release (currently slated to be 3.31.0) and at that time deprecated can be removed as a dependency as well.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants