Skip to content

Replace usage of with await lock (asyncio reactor broken in Python 3.9+)#1270

Merged
absurdfarce merged 1 commit intoapache:trunkfrom
ramikg:fix-asyncio-reactor
Mar 6, 2026
Merged

Replace usage of with await lock (asyncio reactor broken in Python 3.9+)#1270
absurdfarce merged 1 commit intoapache:trunkfrom
ramikg:fix-asyncio-reactor

Conversation

@ramikg
Copy link
Contributor

@ramikg ramikg commented Feb 18, 2026

Trying to connect to Cassandra using the asyncio reactor times out in Python 3.9+.
This is because pushing messages to the queue silently fails due to the usage of the with await asyncio.Lock syntax, removed in Python 3.9.

I've replaced it with async with lock (as suggested by the docs), and now it works.

@ramikg ramikg changed the title Drop usage of with await lock Replace usage of with await lock Feb 22, 2026
@ramikg ramikg changed the title Replace usage of with await lock Replace usage of with await lock (asyncio reactor broken in Python 3.9+) Feb 22, 2026
@absurdfarce
Copy link
Contributor

Yup, this looks right to me. Syntax was changed in Python 3.9 so all the versions we're planning on covering for 3.30.0 should be fine with this change. I'm going to kick off a CI run to confirm there aren't any other unexpected regressions here but I think this should work just as it sits.

Nice find @ramikg!

@absurdfarce
Copy link
Contributor

Jenkins test run looks clean. @bschoening if I can get a 👍 from you I believe we're good to merge this guy.

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

Fixes Python 3.9+ compatibility for the asyncio-based Cassandra reactor by replacing deprecated/removed lock-acquisition syntax so write-queue pushes no longer fail silently and connections don’t time out.

Changes:

  • Replace with await self._write_queue_lock: with async with self._write_queue_lock: in the async write-queue path.

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

@bschoening
Copy link
Contributor

@absurdfarce @ramikg looks good and copilot approves!

patch by ramikg; reviewed by Bret McGuire and Brad Schoening
reference: apache#1270
@absurdfarce absurdfarce force-pushed the fix-asyncio-reactor branch from 1460357 to 8830f0e Compare March 6, 2026 22:09
@absurdfarce absurdfarce merged commit 4842968 into apache:trunk Mar 6, 2026
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.

4 participants