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

Update for Python 3.13 #864

Open
wants to merge 14 commits into
base: 0.12
Choose a base branch
from
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
strategy:
matrix:
os: [ubuntu]
pyver: ['3.7', '3.8', '3.9', '3.10', '3.11']
pyver: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
redis: ['latest']
ujson: ['']
include:
Expand Down Expand Up @@ -87,6 +87,7 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.pyver }}
allow-prereleases: true
cache: 'pip'
cache-dependency-path: '**/requirements*.txt'
- name: Install ujson
Expand Down
2 changes: 1 addition & 1 deletion aiocache/backends/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ async def _redlock_release(self, key, value):
return await self._raw("eval", self.RELEASE_SCRIPT, 1, key, value)

async def _close(self, *args, _conn=None, **kwargs):
await self.client.close()
await self.client.aclose()


class RedisCache(RedisBackend):
Expand Down
18 changes: 9 additions & 9 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
-e .

aiomcache==0.8.0
aiohttp==3.8.3
marshmallow==3.19.0
msgpack==1.0.4
pytest==7.2.0
pytest-asyncio==0.20.3
pytest-cov==4.0.0
pytest-mock==3.10.0
redis==4.4.2
aiomcache==0.8.2
aiohttp==3.9.5
marshmallow==3.21.3
msgpack==1.0.8
pytest==7.4.4
pytest-asyncio==0.23.7
pytest-cov==5.0.0
pytest-mock==3.14.0
redis==5.0.5
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ asyncio_mode = auto
junit_suite_name = aiohttp_test_suite
filterwarnings=
error
# Can be removed once using aiojobs or similar in decorator()
ignore:not awaited:RuntimeWarning
Dreamsorcerer marked this conversation as resolved.
Show resolved Hide resolved
testpaths = tests/
junit_family=xunit2
xfail_strict = true
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
packages=("aiocache",),
install_requires=None,
extras_require={
"redis": ["redis>=4.2.0"],
"redis": ["redis>=5"],
"memcached": ["aiomcache>=0.5.2"],
"msgpack": ["msgpack>=0.5.5"],
},
Expand Down
11 changes: 7 additions & 4 deletions tests/performance/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,25 @@ async def close(self, *_):
await self.cache.close()


cache_key = web.AppKey("cache", CacheManager)


async def handler_get(req):
try:
data = await req.app["cache"].get("testkey")
data = await req.app[cache_key].get("testkey")
if data:
return web.Response(text=data)
except asyncio.TimeoutError:
return web.Response(status=404)

data = str(uuid.uuid4())
await req.app["cache"].set("testkey", data)
await req.app[cache_key].set("testkey", data)
return web.Response(text=str(data))


def run_server(backend: str) -> None:
app = web.Application()
app["cache"] = CacheManager(backend)
app.on_shutdown.append(app["cache"].close)
app[cache_key] = CacheManager(backend)
app.on_shutdown.append(app[cache_key].close)
app.router.add_route("GET", "/", handler_get)
web.run_app(app)
2 changes: 1 addition & 1 deletion tests/ut/backends/test_redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ async def test_redlock_release(self, mocker, redis):

async def test_close(self, redis):
await redis._close()
assert redis.client.close.call_count == 1
assert redis.client.aclose.call_count == 1


class TestRedisCache:
Expand Down
2 changes: 1 addition & 1 deletion tests/ut/test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ async def test_cache_write_waits_for_future(self, decorator, decorator_call):
async def test_cache_write_doesnt_wait_for_future(self, mocker, decorator, decorator_call):
mocker.spy(decorator, "set_in_cache")
with patch.object(decorator, "get_from_cache", autospec=True, return_value=None):
with patch("aiocache.decorators.asyncio.ensure_future", autospec=True):
with patch("aiocache.decorators.asyncio.create_task", autospec=True):
await decorator_call(aiocache_wait_for_write=False, value="value")

decorator.set_in_cache.assert_not_awaited()
Expand Down
Loading