-
Notifications
You must be signed in to change notification settings - Fork 14
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
Make pytest pass locally with Python 3.12 #40
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #40 +/- ##
==========================================
- Coverage 75.02% 75.01% -0.01%
==========================================
Files 132 132
Lines 34352 34368 +16
==========================================
+ Hits 25771 25781 +10
- Misses 8581 8587 +6 ☔ View full report in Codecov by Sentry. |
aiven-sal
reviewed
Jul 10, 2024
aiven-sal
reviewed
Jul 10, 2024
aiven-sal
approved these changes
Jul 11, 2024
Python 3.12 removes `distutils` module completely, as advised in PEP 632. Migration notes [1] advises to reimplement `strtobool` as there is no module that replaces it. The implementation of the function is straighforward since the whole logic is described in `distutils` API reference [2]. This commit reimplements this function to drop `distutils` dependency completely. [1]: https://peps.python.org/pep-0632/#migration-advice [2]: https://docs.python.org/3.9/distutils/apiref.html#distutils.util.strtobool Signed-off-by: Mikhail Koviazin <[email protected]>
`ssl.wrap_socket` was removed in favour of using `SSLContext.wrap_socket`. Creating an SSL context in this scenario is straightforward, as it only needs cert and key files. Signed-off-by: Mikhail Koviazin <[email protected]>
There was a breaking change in `wait_closed()` in Python 3.12 that caused some tests from test_connect to hang indefinitely. The reason for that was the fact that `wait_closed()` was waiting for all handlers to finish their execution, while the handler expected `stop_event` to be set. `stop_event` was set only *after* `wait_closed()` would have finished and returned the control, which caused a deadlock. This commit fixes the deadlock by setting `stop_event` right before calling for `conn.disconnect()`. This makes sense, because at that moment handling more new requests is not needed as connection is going to be closed. The old call for `stop_event.set()` is kept for the unlikely case when there was a connection error and the execution did not reach `stop_event.set()` call in `try` block. If it was reached, this call will be a noop. [1]: python/cpython#104344 Signed-off-by: Mikhail Koviazin <[email protected]>
`NodeProxy` acts as a proxy server that connects to Valkey. In its handler, it creates two pipes: 1. Connecting valkey reader to own writer 2. Connecting own reader to valkey writer Then, it `await`s on these two pipes via `asyncio.gather`. `asyncio.gather` itself returns a future that can be canceled, and originally it was assumingly thought that canceling `self.task` in `NodeProxy` would cancel the pipes, too. That was not the case. This behaviour caused warnings in Python 3.9. On Python 3.12, it caused a deadlock. In order to fix it, the pipes future should be assigned to a variable so that it can be canceled explicitly upon `aclose()`. Additionally, the `NodeProxy`'s handler should handle a situation when pipes future was canceled and close the `Writer` side in order for the loop to end gracefully. This commit introduces `self.pipes` in `NodeProxy` and handles the cancellation properly therefore fixing the deadlock. Signed-off-by: Mikhail Koviazin <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request check-list
Please make sure to review and check all of these items:
NOTE: these things are not required to open a PR and can be done
afterwards / while the PR is open.
Description of change
This is the first PR addressed to fix #24. It contains a smaller amount of changes, but each change is complicated enough to move this bunch into a separate PR.
There will be a second one, fixing calls for
invoke
and some style issues.These commits fix missing dependencies and deadlocks.