diff --git a/modoboa/policyd/core.py b/modoboa/policyd/core.py index 0f8f7c20b..f598271b2 100644 --- a/modoboa/policyd/core.py +++ b/modoboa/policyd/core.py @@ -143,7 +143,7 @@ async def apply_policies(attributes): sasl_username = attributes.get("sasl_username") if not sasl_username: return SUCCESS_ACTION - rclient = await aioredis.create_redis_pool(settings.REDIS_URL) + rclient = aioredis.from_url(settings.REDIS_URL, encoding="utf-8", decode_responses=True) decr_domain = False decr_user = False localpart, domain = split_mailbox(sasl_username) @@ -164,8 +164,7 @@ async def apply_policies(attributes): await decrement_limit(rclient, "domain", domain) if decr_user: await decrement_limit(rclient, "account", sasl_username) - rclient.close() - await rclient.wait_closed() + await rclient.close() logger.debug("Let it pass") return SUCCESS_ACTION @@ -258,16 +257,15 @@ def get_mailboxes_to_reset(): async def reset_counters(): """Reset all counters.""" - rclient = await aioredis.create_redis_pool(settings.REDIS_URL) + rclient = aioredis.from_url(settings.REDIS_URL, encoding="utf-8", decode_responses=True) logger.info("Resetting all counters") for domain in await get_domains_to_reset(): - rclient.hset( + await rclient.hset( constants.REDIS_HASHNAME, domain.name, domain.message_limit) for mb in await get_mailboxes_to_reset(): - rclient.hset( + await rclient.hset( constants.REDIS_HASHNAME, mb.full_address, mb.message_limit) - rclient.close() - await rclient.wait_closed() + await rclient.close() # reschedule asyncio.ensure_future(run_at(get_next_execution_dt(), reset_counters)) diff --git a/requirements.txt b/requirements.txt index a021429e2..439e8788b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,7 +8,7 @@ django-filter dj-database-url -djangorestframework>=3.11,<3.13 +djangorestframework>=3.11,<3.14 drf-spectacular uritemplate djangorestframework-simplejwt==5.1.0 @@ -20,7 +20,7 @@ bcrypt # Requires libffi-dev and python-dev dnspython==2.2.1 feedparser==6.0.8 greenlet==1.1.2 -gevent==21.8.0 +gevent==21.12.0 jsonfield==3.1.0 Pillow # Optional dependency for django-ckeditor progressbar33==2.4 @@ -37,4 +37,4 @@ rrdtool>=0.1.10 qrcode aiosmtplib -aioredis==1.3.1 +aioredis==2.0.1