Skip to content

Commit

Permalink
Merge branch 'master' into enterprise-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dvora-h authored Apr 16, 2024
2 parents cf78401 + 07fc339 commit 45dd0b7
Show file tree
Hide file tree
Showing 38 changed files with 513 additions and 295 deletions.
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ exclude =
ignore =
E126
E203
E701
E704
F405
N801
N802
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
- cron: '0 1 * * *' # nightly build

concurrency:
group: ${{ github.event.pull_request.number || github.ref }}
group: ${{ github.event.pull_request.number || github.ref }}-docs
cancel-in-progress: true

permissions:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
- cron: '0 1 * * *' # nightly build

concurrency:
group: ${{ github.event.pull_request.number || github.ref }}
group: ${{ github.event.pull_request.number || github.ref }}-integration
cancel-in-progress: true

permissions:
Expand Down Expand Up @@ -88,7 +88,7 @@ jobs:
path: '${{matrix.test-type}}*results.xml'

- name: Upload codecov coverage
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: false

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
steps:
# Drafts your next Release notes as Pull Requests are merged into "master"
- uses: release-drafter/release-drafter@v5
- uses: release-drafter/release-drafter@v6
with:
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
config-name: release-drafter-config.yml
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/spellcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Check Spelling
uses: rojopolis/spellcheck-github-actions@0.35.0
uses: rojopolis/spellcheck-github-actions@0.36.0
with:
config_path: .github/spellcheck-settings.yml
task_name: Markdown
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* Allow to control the minimum SSL version
* Add an optional lock_name attribute to LockError.
* Fix return types for `get`, `set_path` and `strappend` in JSONCommands
* Connection.register_connect_callback() is made public.
Expand Down
2 changes: 1 addition & 1 deletion dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
click==8.0.4
black==22.3.0
black==24.3.0
flake8==5.0.4
flake8-isort==6.0.0
flynt~=0.69.0
Expand Down
12 changes: 6 additions & 6 deletions docs/examples/asyncio_examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"\n",
"## Connecting and Disconnecting\n",
"\n",
"Utilizing asyncio Redis requires an explicit disconnect of the connection since there is no asyncio deconstructor magic method. By default, a connection pool is created on `redis.Redis()` and attached to this `Redis` instance. The connection pool closes automatically on the call to `Redis.aclose` which disconnects all connections."
"Using asyncio Redis requires an explicit disconnect of the connection since there is no asyncio deconstructor magic method. By default, an internal connection pool is created on `redis.Redis()` and attached to the `Redis` instance. When calling `Redis.aclose` this internal connection pool closes automatically, which disconnects all connections."
]
},
{
Expand Down Expand Up @@ -48,7 +48,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"If you create custom `ConnectionPool` for the `Redis` instance to use alone, use the `from_pool` class method to create it. This will cause the pool to be disconnected along with the Redis instance. Disconnecting the connection pool simply disconnects all connections hosted in the pool."
"If you create a custom `ConnectionPool` to be used by a single `Redis` instance, use the `Redis.from_pool` class method. The Redis client will take ownership of the connection pool. This will cause the pool to be disconnected along with the Redis instance. Disconnecting the connection pool simply disconnects all connections hosted in the pool."
]
},
{
Expand All @@ -61,7 +61,7 @@
"\n",
"pool = redis.ConnectionPool.from_url(\"redis://localhost\")\n",
"client = redis.Redis.from_pool(pool)\n",
"await client.close()"
"await client.aclose()"
]
},
{
Expand All @@ -74,7 +74,7 @@
},
"source": [
"\n",
"However, If you supply a `ConnectionPool` that is shared several `Redis` instances, you may want to disconnect the connection pool explicitly. use the `connection_pool` argument in that case."
"However, if the `ConnectionPool` is to be shared by several `Redis` instances, you should use the `connection_pool` argument, and you may want to disconnect the connection pool explicitly."
]
},
{
Expand Down Expand Up @@ -201,7 +201,7 @@
"\n",
"async def reader(channel: redis.client.PubSub):\n",
" while True:\n",
" message = await channel.get_message(ignore_subscribe_messages=True)\n",
" message = await channel.get_message(ignore_subscribe_messages=True, timeout=None)\n",
" if message is not None:\n",
" print(f\"(Reader) Message Received: {message}\")\n",
" if message[\"data\"].decode() == STOPWORD:\n",
Expand Down Expand Up @@ -264,7 +264,7 @@
"\n",
"async def reader(channel: redis.client.PubSub):\n",
" while True:\n",
" message = await channel.get_message(ignore_subscribe_messages=True)\n",
" message = await channel.get_message(ignore_subscribe_messages=True, timeout=None)\n",
" if message is not None:\n",
" print(f\"(Reader) Message Received: {message}\")\n",
" if message[\"data\"].decode() == STOPWORD:\n",
Expand Down
36 changes: 36 additions & 0 deletions docs/examples/ssl_connection_examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,42 @@
"ssl_connection.ping()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Connecting to a Redis instance via SSL, while specifying a minimum TLS version"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import redis\n",
"import ssl\n",
"\n",
"ssl_conn = redis.Redis(\n",
" host=\"localhost\",\n",
" port=6666,\n",
" ssl=True,\n",
" ssl_min_version=ssl.TLSVersion.TLSv1_3,\n",
")\n",
"ssl_conn.ping()"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
2 changes: 1 addition & 1 deletion redis/_parsers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ async def can_read_destructive(self) -> bool:
return True
try:
async with async_timeout(0):
return await self._stream.read(1)
return self._stream.at_eof()
except TimeoutError:
return False

Expand Down
31 changes: 16 additions & 15 deletions redis/_parsers/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -831,30 +831,31 @@ def string_keys_to_dict(key_string, callback):
lambda r, **kwargs: r,
),
**string_keys_to_dict("XREAD XREADGROUP", parse_xread_resp3),
"ACL LOG": lambda r: [
{str_if_bytes(key): str_if_bytes(value) for key, value in x.items()} for x in r
]
if isinstance(r, list)
else bool_ok(r),
"ACL LOG": lambda r: (
[
{str_if_bytes(key): str_if_bytes(value) for key, value in x.items()}
for x in r
]
if isinstance(r, list)
else bool_ok(r)
),
"COMMAND": parse_command_resp3,
"CONFIG GET": lambda r: {
str_if_bytes(key)
if key is not None
else None: str_if_bytes(value)
if value is not None
else None
str_if_bytes(key) if key is not None else None: (
str_if_bytes(value) if value is not None else None
)
for key, value in r.items()
},
"MEMORY STATS": lambda r: {str_if_bytes(key): value for key, value in r.items()},
"SENTINEL MASTER": parse_sentinel_state_resp3,
"SENTINEL MASTERS": parse_sentinel_masters_resp3,
"SENTINEL SENTINELS": parse_sentinel_slaves_and_sentinels_resp3,
"SENTINEL SLAVES": parse_sentinel_slaves_and_sentinels_resp3,
"STRALGO": lambda r, **options: {
str_if_bytes(key): str_if_bytes(value) for key, value in r.items()
}
if isinstance(r, dict)
else str_if_bytes(r),
"STRALGO": lambda r, **options: (
{str_if_bytes(key): str_if_bytes(value) for key, value in r.items()}
if isinstance(r, dict)
else str_if_bytes(r)
),
"XINFO CONSUMERS": lambda r: [
{str_if_bytes(key): value for key, value in x.items()} for x in r
],
Expand Down
8 changes: 6 additions & 2 deletions redis/_parsers/resp3.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ def _read_response(self, disable_decoding=False, push_request=False):
)
for _ in range(int(response))
]
self.handle_push_response(response, disable_decoding, push_request)
response = self.handle_push_response(
response, disable_decoding, push_request
)
else:
raise InvalidResponse(f"Protocol Error: {raw!r}")

Expand Down Expand Up @@ -259,7 +261,9 @@ async def _read_response(
)
for _ in range(int(response))
]
await self.handle_push_response(response, disable_decoding, push_request)
response = await self.handle_push_response(
response, disable_decoding, push_request
)
else:
raise InvalidResponse(f"Protocol Error: {raw!r}")

Expand Down
Loading

0 comments on commit 45dd0b7

Please sign in to comment.