CASSPYTHON-18: removed obsolete check for python version > 3.7+#1290
CASSPYTHON-18: removed obsolete check for python version > 3.7+#1290bschoening wants to merge 3 commits intoapache:trunkfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Removes an obsolete Python version guard around the Eventlet + ThreadPoolExecutor workaround, simplifying executor selection now that the driver targets newer Python versions.
Changes:
- Simplified
_create_thread_pool_executorby removing the redundantsys.version_infocheck. - Always attempts to detect Eventlet usage and switches to
futurist.GreenThreadPoolExecutorwhen needed.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
46e86c8 to
abde4ed
Compare
|
There are a number of other spots where sys.version_info is consulted to make decisions about functionality. It's true that all the rest of them are in test code but it might be a good idea to fix all of them in one go anyway: I can make the changes and push a commit to this branch if that's useful. |
| "to hang indefinitely. If you want to use the Eventlet reactor, you " | ||
| "need to install the `futurist` package to allow the driver to use " | ||
| "the GreenThreadPoolExecutor. See https://github.com/eventlet/eventlet/issues/508 " | ||
| "for more details.")) |
There was a problem hiding this comment.
We should perhaps change this usage to be more consistent with the current state of things on two fronts:
- Remove the conditionals on Python versions
- Recommend against eventlet anyways
Maybe something more like the following?
When using eventlet the
concurrent.futures.ThreadPoolExecutorwill hang indefinitely. If you want to use the eventlet reactor, you need to install thefuturistpackage to allow the driver to use the GreenThreadPoolExecutor. See eventlet/eventlet#508 for more details.Note that the eventlet reactor is deprecated and will be removed in 3.31.0. We strongly recommend using the asyncore or libev reactors for production code.
There was a problem hiding this comment.
Hmmm, I'm not even 💯 sure we need this at all. It looks as if eventlet fixed this issue here and that this code was released in version 0.26.0. That version went out in July of 2020 so it's hard to imagine anyone getting an old enough version of eventlet for this to actually be a problem if they did a requirements install today.
abde4ed to
7cdb996
Compare
|
@absurdfarce there are two left which I didn't fully understand, if you could update the PR with changes to those two, that would be terrific. integration/standard/test_metadata.py: if sys.version_info[0:2] != (2, 7): |
|
Gemini suggest the following: @greaterthancass20 |
|
|
||
| @test_category row_factory | ||
| Test for a regression in PYTHON-893. Shouldn't be an issue with currently | ||
| supported versions since the underlying issue was fixed in Python 3.7 |
There was a problem hiding this comment.
The underlying problem is fixed in Python 3.7 (see PYTHON-893 for more on that point) so we should no longer have any case in which NAMEDTUPLE_CREATION_BUG eval's to true.
| with self.VerifiedFunction(self, **kwargs) as vf: | ||
| fn_meta = self.keyspace_function_meta[vf.signature] | ||
| self.assertRegex(fn_meta.as_cql_query(), "CREATE FUNCTION.*\) RETURNS NULL ON NULL INPUT RETURNS .*") | ||
| self.assertRegex(fn_meta.as_cql_query(), "CREATE FUNCTION.*) RETURNS NULL ON NULL INPUT RETURNS .*") |
There was a problem hiding this comment.
Three changes above were minor fixes to address some deprecation warnings noted when running the test via Python 3.10:
tests/integration/standard/test_metadata.py:1591
/home/mersault/work/git/python-driver/tests/integration/standard/test_metadata.py:1591: DeprecationWarning: invalid escape sequence '\('
self.assertRegex(fn_meta.as_cql_query(), "CREATE FUNCTION.*%s\(\) .*" % kwargs['name'])
tests/integration/standard/test_metadata.py:1639
/home/mersault/work/git/python-driver/tests/integration/standard/test_metadata.py:1639: DeprecationWarning: invalid escape sequence '\)'
self.assertRegex(fn_meta.as_cql_query(), "CREATE FUNCTION.*\) CALLED ON NULL INPUT RETURNS .*")
tests/integration/standard/test_metadata.py:1644
/home/mersault/work/git/python-driver/tests/integration/standard/test_metadata.py:1644: DeprecationWarning: invalid escape sequence '\)'
self.assertRegex(fn_meta.as_cql_query(), "CREATE FUNCTION.*\) RETURNS NULL ON NULL INPUT RETURNS .*")
| % (PROTOCOL_VERSION,)) | ||
|
|
||
| if sys.version_info[0:2] != (2, 7): | ||
| raise unittest.SkipTest('This test compares static strings generated from dict items, which may change orders. Test with 2.7.') |
There was a problem hiding this comment.
This is certainly possible, but if we find ourselves in a situation where our output changes because a particular version is handling dictionary keys differently I would much rather know that (by way of a failing test) than silently skipping the test in question.
|
@bschoening Fixes should now be in place for test_row_factories.py and test_metadata.py. I'm going to run Jenkins against the current state of this build to confirm there aren't any unexpected regressions but I think we're getting pretty close. |
No description provided.