Skip to content

CASSPYTHON-13: Remove eventlet, gevent and twisted event loops - #969

Open
mykaul wants to merge 2 commits into
scylladb:masterfrom
mykaul:cherry-pick-CASSPYTHON-13
Open

CASSPYTHON-13: Remove eventlet, gevent and twisted event loops#969
mykaul wants to merge 2 commits into
scylladb:masterfrom
mykaul:cherry-pick-CASSPYTHON-13

Conversation

@mykaul

@mykaul mykaul commented Aug 9, 2026

Copy link
Copy Markdown

Summary

  • Cherry-pick of upstream apache/cassandra-python-driver@8b39688 (CASSPYTHON-13), removing eventlet, gevent, and twisted event loop support and their tests/docs, with conflicts resolved against this fork's divergence (e.g. asyncio in conn_fns, retained is_monkey_patched() helpers used by a fork-specific libev shutdown test).
  • Follow-up commit removes a stale EventletConnection import in Cluster._create_thread_pool_executor — fork-specific code not present upstream, left dead after the reactor module was deleted.

Test plan

  • python3 -m py_compile on all touched files
  • Full tests/unit suite run (no C extensions available in sandbox): 697 passed, 99 skipped (skips due to missing libev/cmurmur3/lz4 extensions, unrelated to this change), 0 failures
  • CI

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: QUIET

Plan: Pro Plus

Run ID: e5a61f19-1e0d-4c11-a729-05b501f40f68

📥 Commits

Reviewing files that changed from the base of the PR and between 69799f1 and a56e602.

📒 Files selected for processing (1)
  • cassandra/datastax/cloud/__init__.py

📝 Walkthrough

Walkthrough

The change removes Eventlet, gevent, and Twisted reactor support from runtime selection, benchmarks, tests, and documentation. Thread pools and queues now use standard-library implementations. Cloud configuration and SSL tests use built-in ssl.SSLContext handling. Cloud ZIP extraction rejects unsafe paths. Supported reactor tests no longer skip under monkey-patched environments.

Possibly related PRs

Suggested labels: P2, area/Driver_-_python-driver

Suggested reviewers: lorak-mmk

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 26.09% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly states the scope, fork-specific considerations, and validation results, but it does not reproduce the repository checklist.
Title check ✅ Passed The title clearly and concisely identifies the removal of eventlet, gevent, and Twisted event-loop support.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Note

Quiet mode is enabled, so only the most important comments were posted inline. Other review comments are grouped below.

🟡 Other comments (1)
docs/installation.rst-172-174 (1)

172-174: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Document pyasyncore installation for Python 3.12+.

pip install scylla-driver does not install pyasyncore. Add a conditional dependency or document python -m pip install pyasyncore beside the driver installation command.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/installation.rst` around lines 172 - 174, Update the Python 3.12+
installation guidance in the asyncore paragraph to explicitly instruct users to
install pyasyncore separately, using the existing driver installation
instructions and a command such as python -m pip install pyasyncore; keep the
note scoped to versions where asyncore is absent.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cassandra/datastax/cloud/__init__.py`:
- Around line 97-102: Harden the extraction flow in the secure-bundle handling
code around ZipFile.extractall by resolving every archive member destination and
rejecting any path outside tmp_dir before extraction. Preserve normal extraction
and parse_cloud_config behavior for safe entries, and add a regression test
covering a traversal archive member.

---

Other comments:
In `@docs/installation.rst`:
- Around line 172-174: Update the Python 3.12+ installation guidance in the
asyncore paragraph to explicitly instruct users to install pyasyncore
separately, using the existing driver installation instructions and a command
such as python -m pip install pyasyncore; keep the note scoped to versions where
asyncore is absent.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: QUIET

Plan: Pro Plus

Run ID: 380ff746-7fd2-4186-a4b6-7db1ee384a86

📥 Commits

Reviewing files that changed from the base of the PR and between 1d7e601 and 8b54528.

📒 Files selected for processing (26)
  • benchmarks/base.py
  • cassandra/cluster.py
  • cassandra/connection.py
  • cassandra/datastax/cloud/__init__.py
  • cassandra/datastax/insights/reporter.py
  • cassandra/io/eventletreactor.py
  • cassandra/io/geventreactor.py
  • cassandra/io/twistedreactor.py
  • docs/api/cassandra/io/eventletreactor.rst
  • docs/api/cassandra/io/geventreactor.rst
  • docs/api/cassandra/io/twistedreactor.rst
  • docs/api/index.rst
  • docs/installation.rst
  • docs/security.rst
  • tests/__init__.py
  • tests/integration/long/test_ssl.py
  • tests/integration/standard/test_connection.py
  • tests/unit/io/eventlet_utils.py
  • tests/unit/io/gevent_utils.py
  • tests/unit/io/test_asyncioreactor.py
  • tests/unit/io/test_asyncorereactor.py
  • tests/unit/io/test_eventletreactor.py
  • tests/unit/io/test_geventreactor.py
  • tests/unit/io/test_libevreactor.py
  • tests/unit/io/test_twistedreactor.py
  • tests/unit/io/utils.py
💤 Files with no reviewable changes (16)
  • docs/api/cassandra/io/eventletreactor.rst
  • docs/api/cassandra/io/geventreactor.rst
  • tests/unit/io/test_eventletreactor.py
  • tests/unit/io/utils.py
  • benchmarks/base.py
  • cassandra/io/twistedreactor.py
  • tests/unit/io/test_geventreactor.py
  • docs/security.rst
  • tests/unit/io/gevent_utils.py
  • cassandra/io/eventletreactor.py
  • docs/api/index.rst
  • tests/unit/io/test_twistedreactor.py
  • tests/unit/io/eventlet_utils.py
  • tests/integration/standard/test_connection.py
  • cassandra/io/geventreactor.py
  • docs/api/cassandra/io/twistedreactor.rst

Comment thread cassandra/datastax/cloud/__init__.py
@mykaul
mykaul force-pushed the cherry-pick-CASSPYTHON-13 branch 3 times, most recently from e97d2dd to 69799f1 Compare August 12, 2026 05:47
@mykaul
mykaul marked this pull request as ready for review August 12, 2026 07:46
@mykaul

mykaul commented Aug 12, 2026

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
⚠️ Action not completed

Already reviewed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Note

Quiet mode is enabled, so only the most important comments were posted inline. Other review comments are grouped below.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
cassandra/datastax/cloud/__init__.py (1)

129-129: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Enable hostname verification for the metadata TLS context.

_ssl_context_from_cert leaves check_hostname disabled. The later ssl_options setting does not modify the supplied context. Set ssl_context.check_hostname = True and add a wrong-hostname regression test.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cassandra/datastax/cloud/__init__.py` at line 129, Update the metadata TLS
setup in the surrounding cloud configuration flow to set
ssl_context.check_hostname = True immediately after _ssl_context_from_cert
returns. Add a regression test that uses a certificate for the wrong hostname
and verifies the TLS connection is rejected.

Sources: Coding guidelines, MCP tools

🟡 Other comments (2)
cassandra/datastax/cloud/__init__.py-87-88 (1)

87-88: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Preserve the BadZipFile cause.

Ruff B904 flags this translation. Bind the exception and raise the ValueError with from err.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cassandra/datastax/cloud/__init__.py` around lines 87 - 88, Update the
BadZipFile handler to bind the caught exception and raise the existing
ValueError using that exception as its explicit cause via from err, preserving
the current message.

Sources: Coding guidelines, Linters/SAST tools

CONTRIBUTING.rst-76-76 (1)

76-76: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Fail when the asyncio reactor test skips.

Line 76 omits CASS_DRIVER_NO_SKIP=1, while the corresponding CI command sets it to prevent skipped tests from passing. Add the variable so this command cannot report success without running the asyncio reactor test.

Proposed fix
-    EVENT_LOOP_MANAGER=asyncio uv run pytest tests/unit/io/test_asyncioreactor.py
+    CASS_DRIVER_NO_SKIP=1 EVENT_LOOP_MANAGER=asyncio uv run pytest tests/unit/io/test_asyncioreactor.py
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@CONTRIBUTING.rst` at line 76, Add CASS_DRIVER_NO_SKIP=1 to the documented
pytest command for test_asyncioreactor.py, alongside EVENT_LOOP_MANAGER=asyncio,
so skipped asyncio reactor tests cause the command to fail.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@cassandra/datastax/cloud/__init__.py`:
- Line 129: Update the metadata TLS setup in the surrounding cloud configuration
flow to set ssl_context.check_hostname = True immediately after
_ssl_context_from_cert returns. Add a regression test that uses a certificate
for the wrong hostname and verifies the TLS connection is rejected.

---

Other comments:
In `@cassandra/datastax/cloud/__init__.py`:
- Around line 87-88: Update the BadZipFile handler to bind the caught exception
and raise the existing ValueError using that exception as its explicit cause via
from err, preserving the current message.

In `@CONTRIBUTING.rst`:
- Line 76: Add CASS_DRIVER_NO_SKIP=1 to the documented pytest command for
test_asyncioreactor.py, alongside EVENT_LOOP_MANAGER=asyncio, so skipped asyncio
reactor tests cause the command to fail.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: QUIET

Plan: Pro Plus

Run ID: cbe95ed5-fb57-4807-89d6-edfdf362ea68

📥 Commits

Reviewing files that changed from the base of the PR and between 8b54528 and 69799f1.

📒 Files selected for processing (3)
  • CONTRIBUTING.rst
  • cassandra/datastax/cloud/__init__.py
  • pyproject.toml

brettabamonte and others added 2 commits August 12, 2026 12:08
patch by Brett Abamonte; reviewed by Bret McGuire

(cherry picked from commit 8b39688)
…hread_pool_executor

This code path in cassandra/cluster.py was not part of the original
upstream removal since it doesn't exist upstream; it's fork-specific.
With eventletreactor deleted, the import always failed and the method
always fell back to a plain ThreadPoolExecutor, so drop the dead branch.
@mykaul
mykaul force-pushed the cherry-pick-CASSPYTHON-13 branch from a56e602 to 0601f4d Compare August 12, 2026 09:09
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.

2 participants