Skip to content
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

Support the deprecation of asyncore in python 3.12 #260

Merged
merged 5 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-experimental.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [push, pull_request]
env:
CIBW_BEFORE_BUILD_LINUX: "rm -rf ~/.pyxbld && yum install -y libev libev-devel openssl openssl-devel"
CIBW_ENVIRONMENT: "CASS_DRIVER_BUILD_CONCURRENCY=2 CFLAGS='-g0 -O3'"
CIBW_BUILD: "cp38* cp39* cp310* cp311*"
CIBW_BUILD: "cp39* cp310* cp311* cp312*"
Lorak-mmk marked this conversation as resolved.
Show resolved Hide resolved
CIBW_SKIP: "*musllinux*"
jobs:
build_wheels:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ env:
CIBW_BEFORE_TEST: "pip install -r {project}/test-requirements.txt"
CIBW_BEFORE_BUILD_LINUX: "rm -rf ~/.pyxbld && yum install -y libffi-devel libev libev-devel openssl openssl-devel"
CIBW_ENVIRONMENT: "CASS_DRIVER_BUILD_CONCURRENCY=2 CFLAGS='-g0 -O3'"
CIBW_SKIP: cp35* cp36* *musllinux* cp312*
CIBW_SKIP: cp35* cp36* *musllinux*
Lorak-mmk marked this conversation as resolved.
Show resolved Hide resolved

jobs:
build_wheels:
Expand Down
19 changes: 14 additions & 5 deletions cassandra/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@

try:
from cassandra.io.eventletreactor import EventletConnection
except ImportError:
except (ImportError, AttributeError):
# AttributeError was add for handling python 3.12 https://github.com/eventlet/eventlet/issues/812
# TODO: remove it when eventlet issue would be fixed
EventletConnection = None

try:
Expand All @@ -115,9 +117,13 @@
def _is_eventlet_monkey_patched():
if 'eventlet.patcher' not in sys.modules:
return False
import eventlet.patcher
return eventlet.patcher.is_monkey_patched('socket')

try:
import eventlet.patcher
return eventlet.patcher.is_monkey_patched('socket')
except (ImportError, AttributeError):
# AttributeError was add for handling python 3.12 https://github.com/eventlet/eventlet/issues/812
# TODO: remove it when eventlet issue would be fixed
return False

def _is_gevent_monkey_patched():
if 'gevent.monkey' not in sys.modules:
Expand All @@ -137,7 +143,10 @@ def _is_gevent_monkey_patched():
try:
from cassandra.io.libevreactor import LibevConnection as DefaultConnection # NOQA
except ImportError:
from cassandra.io.asyncorereactor import AsyncoreConnection as DefaultConnection # NOQA
try:
from cassandra.io.asyncorereactor import AsyncoreConnection as DefaultConnection # NOQA
except ImportError:
from cassandra.io.asyncioreactor import AsyncioConnection as DefaultConnection # NOQA

# Forces load of utf8 encoding module to avoid deadlock that occurs
# if code that is being imported tries to import the module in a seperate
Expand Down
1 change: 0 additions & 1 deletion tests/integration/standard/test_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import asyncore
import subprocess

import unittest
Expand Down
8 changes: 6 additions & 2 deletions tests/integration/standard/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@

from cassandra import ConsistencyLevel, OperationTimedOut
from cassandra.cluster import NoHostAvailable, ConnectionShutdown, ExecutionProfile, EXEC_PROFILE_DEFAULT
import cassandra.io.asyncorereactor
from cassandra.io.asyncorereactor import AsyncoreConnection

try:
from cassandra.io.asyncorereactor import AsyncoreConnection
except ImportError:
AsyncoreConnection = None

from cassandra.protocol import QueryMessage
from cassandra.connection import Connection
from cassandra.policies import HostFilterPolicy, RoundRobinPolicy, HostStateListener
Expand Down
19 changes: 13 additions & 6 deletions tests/integration/standard/test_scylla_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,22 @@

from tests.integration import use_cluster
from cassandra.cluster import Cluster, TwistedConnection
from cassandra.io.asyncorereactor import AsyncoreConnection


from cassandra.io.libevreactor import LibevConnection
from cassandra.io.geventreactor import GeventConnection
from cassandra.io.eventletreactor import EventletConnection
from cassandra.io.asyncioreactor import AsyncioConnection
supported_connection_classes = [LibevConnection, TwistedConnection]
try:
from cassandra.io.asyncorereactor import AsyncoreConnection
supported_connection_classes += [AsyncoreConnection]
except ImportError:
pass

#from cassandra.io.geventreactor import GeventConnection
#from cassandra.io.eventletreactor import EventletConnection
#from cassandra.io.asyncioreactor import AsyncioConnection

supported_connection_classes = [AsyncoreConnection, LibevConnection, TwistedConnection]
# need to run them with specific configuration like `gevent.monkey.patch_all()` or under async functions
unsupported_connection_classes = [GeventConnection, AsyncioConnection, EventletConnection]
# unsupported_connection_classes = [GeventConnection, AsyncioConnection, EventletConnection]

Choose a reason for hiding this comment

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

I don't immediately see why wouldn't AsyncioConnection work here. Did you try to run this test with it?
Also, is commenting out this line and 3 imports necessary?

Copy link
Author

Choose a reason for hiding this comment

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

Asyncio wasn't working at all when those tests were written, so I didn't introduce it now

As for the comment, I rather not import the unused classes, it was for documenting only, and import of some of them now complicates things



class ScyllaCloudConfigTests(TestCase):
Expand Down