diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ab4bf5aa..fbb3f94e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -8,10 +8,10 @@ jobs: deploy: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: '3.x' diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d99bc947..da4d02d5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,6 +9,10 @@ jobs: strategy: matrix: python-version: [3.7.7, 3.8, 3.9, 3.10.2] + aioredis-dep: ["aioredis==1.3.1", "evo-aioredis==1.3.4"] + include: + - python-version: 3.11 + aioredis-dep: "evo-aioredis==1.3.4" env: PYTHON: ${{ matrix.python-version }} @@ -33,6 +37,7 @@ jobs: python -m pip install --upgrade pip setuptools pip install -r requirements.txt pip install -e .[watch] + pip install ${{ matrix.aioredis-dep }} - name: Lint with mypy run: mypy darq/ diff --git a/CHANGES.rst b/CHANGES.rst index 814e36cd..199f852e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,6 +6,7 @@ Changelog 0.11.1 (unreleased) ................... * Remove ``pydantic`` dependency +* Remove ``aioredis`` from dependencies to allow choose between ``aioredis`` and ``evo-aioredis`` - fork with Python 3.11 compatability 0.11.0 (2022-08-03) ................... diff --git a/README.rst b/README.rst index 613cc6d7..71c3fe60 100644 --- a/README.rst +++ b/README.rst @@ -21,6 +21,25 @@ Features * Graceful shutdown: waits until running tasks are finished +Installation +------------ +Darq uses ``aioredis`` 1.x as Redis client. Unfortunately, this library has been abandoned, and does not support Python 3.11. I made a fork with compatability fixes: ``evo-aioredis`` (https://github.com/evo-company/aioredis-py). + +Because of this, ``aioredis`` is not currently added as Darq dependency, and you must install it yourself: + +For Python<3.11 you can use: + +.. code:: shell + + pip install aioredis<2.0.0 + +For Python 3.11 (and older versions too) you can use fork: + +.. code:: shell + + pip install evo-aioredis<2.0.0 + + Quick start ----------- diff --git a/darq/__init__.py b/darq/__init__.py index 8937c50b..0bf4a07a 100644 --- a/darq/__init__.py +++ b/darq/__init__.py @@ -5,4 +5,14 @@ from .version import __version__ from .worker import Retry +try: + from aioredis import __version__ as aioredis_version +except ImportError: + raise ImportError( + 'Please, install "aioredis" (or "evo-aioredis" - for Python 3.11+)') + +AIOREDIS_MAJOR_VERSION = int(aioredis_version.split('.')[0]) +if AIOREDIS_MAJOR_VERSION > 1: + raise ImportError('Darq only supports "aioredis" versions <2.0') + __all__ = ['Darq', 'JobCtx', 'RedisSettings', 'cron', 'Retry', '__version__'] diff --git a/setup.py b/setup.py index 011c12b5..36e20d8b 100644 --- a/setup.py +++ b/setup.py @@ -38,6 +38,7 @@ def readfile(filename: str) -> str: 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', 'Typing :: Typed', ], entry_points={ @@ -45,7 +46,6 @@ def readfile(filename: str) -> str: }, install_requires=[ 'async-timeout>=3.0.0, <5.0', - 'aioredis>=1.1.0, <2.0', 'click>=6.7', 'typing_extensions>=4.0; python_version<"3.8"', ], diff --git a/tests/requirements.txt b/tests/requirements.txt index 9c11bfd6..4471f5dd 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -2,7 +2,6 @@ pytest==7.2.0 pytest-aiohttp==1.0.4 pytest-mock==3.10.0 pytest-cov==4.0.0 -asynctest==0.13.0 mypy==0.982 flake8==5.0.4 flake8-quotes==3.3.1 diff --git a/tests/test_app.py b/tests/test_app.py index 47c84976..2b6a4bf6 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -1,11 +1,12 @@ +import asyncio import datetime import logging import re from unittest.mock import call +from unittest.mock import Mock +from unittest.mock import patch import pytest -from asynctest import CoroutineMock -from asynctest import patch from darq import Darq from darq.app import DarqConnectionError @@ -174,9 +175,15 @@ async def prepublish_side_effect( 'job_try': None, } - on_job_prerun = CoroutineMock() - on_job_postrun = CoroutineMock() - on_job_prepublish = CoroutineMock(side_effect=prepublish_side_effect) + on_job_prerun_future = asyncio.Future() + on_job_prerun_future.set_result(None) + on_job_prerun = Mock(return_value=on_job_prerun_future) + + on_job_postrun_future = asyncio.Future() + on_job_postrun_future.set_result(None) + on_job_postrun = Mock(return_value=on_job_postrun_future) + + on_job_prepublish = Mock(side_effect=prepublish_side_effect) darq = Darq( redis_settings=redis_settings,