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

Drop python 3.6 support #2306

Merged
merged 1 commit into from
Jul 27, 2022
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
4 changes: 2 additions & 2 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
strategy:
max-parallel: 15
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10', 'pypy-3.7', 'pypy-3.8']
python-version: ['3.7', '3.8', '3.9', '3.10', 'pypy-3.7', 'pypy-3.8']
test-type: ['standalone', 'cluster']
connection-type: ['hiredis', 'plain']
env:
Expand Down Expand Up @@ -84,7 +84,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10', 'pypy-3.7']
python-version: ['3.7', '3.8', '3.9', '3.10', 'pypy-3.7']
steps:
- uses: actions/checkout@v2
- name: install python ${{ matrix.python-version }}
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ this, instead of using make test, you need to pass
Our test suite uses `pytest`. You can run a specific test suite against
a specific Python version like this:

`$ docker-compose run test tox -e py36 -- --redis-url=redis://master:6379/9 tests/test_commands.py`
`$ docker-compose run test tox -e py37 -- --redis-url=redis://master:6379/9 tests/test_commands.py`

### Troubleshooting

Expand Down
6 changes: 2 additions & 4 deletions redis/asyncio/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,7 @@ def __del__(self) -> None:
warnings.warn(f"{self._DEL_MESSAGE} {self!r}", ResourceWarning, source=self)
try:
context = {"client": self, "message": self._DEL_MESSAGE}
# TODO: Change to get_running_loop() when dropping support for py3.6
asyncio.get_event_loop().call_exception_handler(context)
asyncio.get_running_loop().call_exception_handler(context)
except RuntimeError:
...

Expand Down Expand Up @@ -834,8 +833,7 @@ def __del__(self) -> None:
)
try:
context = {"client": self, "message": self._DEL_MESSAGE}
# TODO: Change to get_running_loop() when dropping support for py3.6
asyncio.get_event_loop().call_exception_handler(context)
asyncio.get_running_loop().call_exception_handler(context)
except RuntimeError:
...
break
Expand Down
25 changes: 8 additions & 17 deletions redis/asyncio/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import os
import socket
import ssl
import sys
import threading
import weakref
from itertools import chain
Expand Down Expand Up @@ -864,12 +863,10 @@ async def _ping_failed(self, error):

async def check_health(self):
"""Check the health of the connection with a PING/PONG"""
if sys.version_info[0:2] == (3, 6):
func = asyncio.get_event_loop
else:
func = asyncio.get_running_loop

if self.health_check_interval and func().time() > self.next_health_check:
if (
self.health_check_interval
and asyncio.get_running_loop().time() > self.next_health_check
):
await self.retry.call_with_retry(self._send_ping, self._ping_failed)

async def _send_packed_command(self, command: Iterable[bytes]) -> None:
Expand Down Expand Up @@ -957,11 +954,8 @@ async def read_response(self, disable_decoding: bool = False):
raise

if self.health_check_interval:
if sys.version_info[0:2] == (3, 6):
func = asyncio.get_event_loop
else:
func = asyncio.get_running_loop
self.next_health_check = func().time() + self.health_check_interval
next_time = asyncio.get_running_loop().time() + self.health_check_interval
self.next_health_check = next_time

if isinstance(response, ResponseError):
raise response from None
Expand Down Expand Up @@ -992,11 +986,8 @@ async def read_response_without_lock(self, disable_decoding: bool = False):
raise

if self.health_check_interval:
if sys.version_info[0:2] == (3, 6):
func = asyncio.get_event_loop
else:
func = asyncio.get_running_loop
self.next_health_check = func().time() + self.health_check_interval
next_time = asyncio.get_running_loop().time() + self.health_check_interval
self.next_health_check = next_time

if isinstance(response, ResponseError):
raise response from None
Expand Down
10 changes: 2 additions & 8 deletions redis/asyncio/lock.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import asyncio
import sys
import threading
import uuid
from types import SimpleNamespace
Expand Down Expand Up @@ -186,11 +185,6 @@ async def acquire(
object with the default encoding. If a token isn't specified, a UUID
will be generated.
"""
if sys.version_info[0:2] != (3, 6):
loop = asyncio.get_running_loop()
else:
loop = asyncio.get_event_loop()

sleep = self.sleep
if token is None:
token = uuid.uuid1().hex.encode()
Expand All @@ -203,14 +197,14 @@ async def acquire(
blocking_timeout = self.blocking_timeout
stop_trying_at = None
if blocking_timeout is not None:
stop_trying_at = loop.time() + blocking_timeout
stop_trying_at = asyncio.get_event_loop().time() + blocking_timeout
while True:
if await self.do_acquire(token):
self.local.token = token
return True
if not blocking:
return False
next_try_at = loop.time() + sleep
next_try_at = asyncio.get_event_loop().time() + sleep
if stop_trying_at is not None and next_try_at > stop_trying_at:
return False
await asyncio.sleep(sleep)
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
author="Redis Inc.",
author_email="oss@redis.com",
python_requires=">=3.6",
python_requires=">=3.7",
install_requires=[
"deprecated>=1.2.3",
"packaging>=20.4",
Expand All @@ -47,7 +47,6 @@
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
Expand Down
27 changes: 4 additions & 23 deletions tests/test_asyncio/conftest.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import functools
import random
import sys
from contextlib import asynccontextmanager as _asynccontextmanager
from typing import Union
from urllib.parse import urlparse

import pytest
import pytest_asyncio
from packaging.version import Version

import redis.asyncio as redis
Expand All @@ -21,13 +21,6 @@

from .compat import mock

if sys.version_info[0:2] == (3, 6):
import pytest as pytest_asyncio

pytestmark = pytest.mark.asyncio
else:
import pytest_asyncio


async def _get_info(redis_url):
client = redis.Redis.from_url(redis_url)
Expand Down Expand Up @@ -268,17 +261,5 @@ async def __aexit__(self, exc_type, exc_inst, tb):
raise RuntimeError("More pickles")


if sys.version_info[0:2] == (3, 6):

def asynccontextmanager(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
return AsyncContextManager(func(*args, **kwargs))

return wrapper

else:
from contextlib import asynccontextmanager as _asynccontextmanager

def asynccontextmanager(func):
return _asynccontextmanager(func)
def asynccontextmanager(func):
return _asynccontextmanager(func)
5 changes: 0 additions & 5 deletions tests/test_asyncio/test_bloom.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import sys

import pytest

import redis.asyncio as redis
from redis.exceptions import ModuleError, RedisError
from redis.utils import HIREDIS_AVAILABLE

if sys.version_info[0:2] == (3, 6):
pytestmark = pytest.mark.asyncio


def intlist(obj):
return [int(v) for v in obj]
Expand Down
14 changes: 3 additions & 11 deletions tests/test_asyncio/test_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,12 @@
import binascii
import datetime
import os
import sys
import warnings
from typing import Any, Awaitable, Callable, Dict, List, Optional, Type, Union
from urllib.parse import urlparse

import pytest

from .compat import mock

if sys.version_info[0:2] == (3, 6):
import pytest as pytest_asyncio

pytestmark = pytest.mark.asyncio
else:
import pytest_asyncio

import pytest_asyncio
from _pytest.fixtures import FixtureRequest

from redis.asyncio.cluster import ClusterNode, NodesManager, RedisCluster
Expand All @@ -44,6 +34,8 @@
skip_unless_arch_bits,
)

from .compat import mock

pytestmark = pytest.mark.onlycluster


Expand Down
9 changes: 1 addition & 8 deletions tests/test_asyncio/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,11 @@
import binascii
import datetime
import re
import sys
import time
from string import ascii_letters

import pytest

if sys.version_info[0:2] == (3, 6):
import pytest as pytest_asyncio

pytestmark = pytest.mark.asyncio
else:
import pytest_asyncio
import pytest_asyncio

import redis
from redis import exceptions
Expand Down
4 changes: 0 additions & 4 deletions tests/test_asyncio/test_connection.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import asyncio
import socket
import sys
import types
from unittest.mock import patch

Expand All @@ -19,9 +18,6 @@

from .compat import mock

if sys.version_info[0:2] == (3, 6):
pytestmark = pytest.mark.asyncio


@pytest.mark.onlynoncluster
@pytest.mark.skipif(HIREDIS_AVAILABLE, reason="PythonParser only")
Expand Down
9 changes: 1 addition & 8 deletions tests/test_asyncio/test_connection_pool.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import asyncio
import os
import re
import sys

import pytest

if sys.version_info[0:2] == (3, 6):
import pytest as pytest_asyncio

pytestmark = pytest.mark.asyncio
else:
import pytest_asyncio
import pytest_asyncio

import redis.asyncio as redis
from redis.asyncio.connection import Connection, to_bool
Expand Down
10 changes: 1 addition & 9 deletions tests/test_asyncio/test_encoding.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
import sys

import pytest

if sys.version_info[0:2] == (3, 6):
import pytest as pytest_asyncio

pytestmark = pytest.mark.asyncio
else:
import pytest_asyncio
import pytest_asyncio

import redis.asyncio as redis
from redis.exceptions import DataError
Expand Down
9 changes: 1 addition & 8 deletions tests/test_asyncio/test_lock.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import asyncio
import sys

import pytest

if sys.version_info[0:2] == (3, 6):
import pytest as pytest_asyncio

pytestmark = pytest.mark.asyncio
else:
import pytest_asyncio
import pytest_asyncio

from redis.asyncio.lock import Lock
from redis.exceptions import LockError, LockNotOwnedError
Expand Down
5 changes: 0 additions & 5 deletions tests/test_asyncio/test_monitor.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import sys

import pytest

from tests.conftest import skip_if_redis_enterprise, skip_ifnot_redis_enterprise

from .conftest import wait_for_command

if sys.version_info[0:2] == (3, 6):
pytestmark = pytest.mark.asyncio


@pytest.mark.onlynoncluster
class TestMonitor:
Expand Down
5 changes: 0 additions & 5 deletions tests/test_asyncio/test_pipeline.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import sys

import pytest

import redis
from tests.conftest import skip_if_server_version_lt

from .conftest import wait_for_command

if sys.version_info[0:2] == (3, 6):
pytestmark = pytest.mark.asyncio


class TestPipeline:
@pytest.mark.onlynoncluster
Expand Down
9 changes: 1 addition & 8 deletions tests/test_asyncio/test_pubsub.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import asyncio
import functools
import sys
from typing import Optional

import async_timeout
import pytest

if sys.version_info[0:2] == (3, 6):
import pytest as pytest_asyncio

pytestmark = pytest.mark.asyncio(forbid_global_loop=True)
else:
import pytest_asyncio
import pytest_asyncio

import redis.asyncio as redis
from redis.exceptions import ConnectionError
Expand Down
10 changes: 1 addition & 9 deletions tests/test_asyncio/test_scripting.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
import sys

import pytest

if sys.version_info[0:2] == (3, 6):
import pytest as pytest_asyncio

pytestmark = pytest.mark.asyncio
else:
import pytest_asyncio
import pytest_asyncio

from redis import exceptions
from tests.conftest import skip_if_server_version_lt
Expand Down
Loading