Skip to content

skip ssl import if not available #1

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

Open
wants to merge 198 commits into
base: master
Choose a base branch
from
Open

skip ssl import if not available #1

wants to merge 198 commits into from

Conversation

dicej
Copy link
Owner

@dicej dicej commented Dec 18, 2023

utils.py has support for detecting whether the ssl module is available, and we can use this to omit SSL-specific funcionality while still providing other features (e.g. unencrypted connections).

Prior to this patch, the connection.py modules both triggered an ImportError due to unconditional imports of the ssl module. Now, we check utils.SSL_AVAILABLE prior to attempting the import and only raise an error later if (and only if) the application requests an encrypted connection. This helps support platforms such as wasm32-wasi where the ssl module is not built by default.

Pull Request check-list

Please make sure to review and check all of these items:

  • Do tests and lints pass with this change?
  • Do the CI tests pass with this change (enable it first in your forked repo and wait for the github action build to finish)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Is there an example added to the examples folder (if applicable)?
  • Was the change added to CHANGES file?

NOTE: these things are not required to open a PR and can be done
afterwards / while the PR is open.

Description of change

Please provide a description of the change here.

@dicej dicej force-pushed the no-ssl branch 4 times, most recently from 6daa3cd to ae2e1bd Compare December 18, 2023 17:09
dvora-h and others added 26 commits January 1, 2024 12:13
* cache invalidations

* isort

* deamon thread

* remove threads

* delete comment

* tests

* skip if hiredis available

* async

* review comments

* docstring

* decode test

* fix test

* fix decode response test
* Drop typing_extensions dependency (not necessary when targeting Python 3.8+)

* Bump python_requires to >=3.8, drop importlib-metadata shim dependency

* Cease testing on Python 3.7

* Add 3.8 test

---------

Co-authored-by: dvora-h <[email protected]>
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2 to 3.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](github/codeql-action@v2...v3)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3 to 4.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](actions/upload-artifact@v3...v4)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4 to 5.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](actions/setup-python@v4...v5)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* sync

* async

* fixs connection mocks

* fix async connection mock

* fix test_asyncio/test_connection.py::test_single_connection

* add test for cache blacklist and flushdb at the end of each test

* fix review comments
* sync

* fix mock_node_resp

* fix mock_node_resp_func

* fix test_handling_cluster_failover_to_a_replica

* fix test_handling_cluster_failover_to_a_replica

* async cluster and cleanup tests

* delete comment
* Adding lock_name to LockError

* Adding lock_name to LockError

---------

Co-authored-by: dvora-h <[email protected]>
* Fix objlen type hint

* Update redis/commands/json/commands.py

Co-authored-by: dvora-h <[email protected]>

* linters

---------

Co-authored-by: dvora-h <[email protected]>
* Update cluster.py

When Executing "n.write()" may generate some unknown errors(e.g. DataError), which could result in the connection not being released.

* Update cluster.py

* Update cluster.py

release connection move to "try...finally"

* Update cluster.py

 fix the linters

* fix problems of code review
…dd AbstractCache class (redis#3110)

* CSC review fixes

* cahnge cache_max_size default value

* use ABC and add docstring
666romeo and others added 22 commits February 27, 2025 14:58
* Fixing typing for FCALL commands to match PEP 484

* Codestyle fixes

* Fixes issue redis#3536
* fix(lock): raise LockNotOwnedError when release a lock from non-owned thread

* change: error raise

* fix: linter

* fix(lock): async release

---------

Co-authored-by: Vladyslav Vildanov <[email protected]>
…#3538)

Bumps [rojopolis/spellcheck-github-actions](https://github.com/rojopolis/spellcheck-github-actions) from 0.38.0 to 0.47.0.
- [Release notes](https://github.com/rojopolis/spellcheck-github-actions/releases)
- [Changelog](https://github.com/rojopolis/spellcheck-github-actions/blob/master/CHANGELOG.md)
- [Commits](rojopolis/spellcheck-github-actions@0.38.0...0.47.0)

---
updated-dependencies:
- dependency-name: rojopolis/spellcheck-github-actions
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: petyaslavova <[email protected]>
…re provided and health check interval is configured (redis#3477)
* Replace flake8 + isort + flynt with ruff

* Replace black with `ruff format`; run it
* (tests): Added testing for auth via DefaultAzureCredential

* Added testing for async

* Remove unused import
… after lock expiration (redis#3531)

* adds option not to raise when leaving context manager after lock expiration

* keep oroginal traceback

Co-authored-by: Aarni Koskela <[email protected]>

* improves error traceback

* adds missing modifications

* sort imports

* run linter

* adds catch for other possible exception

* Update redis/lock.py to catch Both LockNotOwnedError and LockError in one except statement as LockError.

Co-authored-by: Juliano Amadeu <[email protected]>

* Update redis/asyncio/lock.py

Co-authored-by: Juliano Amadeu <[email protected]>

* fix linter errors

---------

Co-authored-by: Aarni Koskela <[email protected]>
Co-authored-by: petyaslavova <[email protected]>
Client.close() may call ConnectionPool.release() or
ConnectionPool.disconnect(); both methods may end up calling
os.getpid() (through ConnectionPool._checkpid() or threading.Lock()
(through ConnectionPool.reset()). As mentioned in the Python
documentation [1], at interpreter shutdown, module globals (in this
case, the os and threading module references) may be deleted or set to
None before __del__() methods are called. This causes an
AttributeError to be raised when trying to run e.g. os.getpid(); while
the error is ignored by the interpreter, the traceback is still
printed out to stderr.

Closes redis#3014

[1] https://docs.python.org/3/reference/datamodel.html#object.__del__

Co-authored-by: petyaslavova <[email protected]>
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.