Skip to content
This repository has been archived by the owner on Feb 21, 2023. It is now read-only.

RuntimeError: coroutine ignored GeneratorExit #1137

Open
1 task done
Tracked by #1225
kwint opened this issue Sep 23, 2021 · 3 comments
Open
1 task done
Tracked by #1225

RuntimeError: coroutine ignored GeneratorExit #1137

kwint opened this issue Sep 23, 2021 · 3 comments
Labels

Comments

@kwint
Copy link

kwint commented Sep 23, 2021

Describe the bug

We migrated to aioredis 2.0 this week and we are seeing this error showing up once and again.
Unfortunately I have no clue how to reproduce it, it seems to happen randomly when setting a variable. It feels like the exception is showing up more and more often as the program runs. The code runs on multiple machines and we see the same issue on all of them

To Reproduce

I dont have a reliable way to reproduce this, but this is the function in which it happens:

async def rd_set(key, data, host="redis", port=6379):
    try:
        # Connect to redis & set key
        rd = await aioredis.from_url(
            f"redis://{host}:{port}", encoding="utf-8", decode_responses=True
        )
        async with rd.client() as conn:
            await conn.set(key, data)

    except ConnectionRefusedError:
        send_warning()
        logger.error(f"Unable to connect to redis, key '{key}' not updated!")

Expected behavior

We expect the function to not throw an exception and continue quietly

Logs/tracebacks

hub_1        | Traceback (most recent call last):
hub_1        |   File "/code/metal_hub/handlers/redis.py", line 48, in handle_event
hub_1        |     await rd_set("state", event.value)
hub_1        |   File "/code/metal_hub/handlers/redis.py", line 83, in rd_set
hub_1        |     await conn.set(key, data)
hub_1        |   File "/usr/local/lib/python3.8/site-packages/aioredis/client.py", line 1064, in execute_command
hub_1        |     return await self.parse_response(conn, command_name, **options)
hub_1        |   File "/usr/local/lib/python3.8/site-packages/aioredis/client.py", line 1080, in parse_response
hub_1        |     response = await connection.read_response()
hub_1        | RuntimeError: coroutine ignored GeneratorExit

Python Version

Python 3.8.12

aioredis Version

Name: aioredis
Version: 2.0.0
Summary: asyncio (PEP 3156) Redis support
Home-page: https://github.com/aio-libs/aioredis
Author:
Author-email:
License: MIT
Location: /usr/local/lib/python3.8/site-packages
Requires: typing-extensions, async-timeout
Required-by:

Additional context

No response

Code of Conduct

  • I agree to follow the aio-libs Code of Conduct
@kwint kwint added the bug label Sep 23, 2021
@kwint
Copy link
Author

kwint commented Sep 23, 2021

Looks like installing hiredis has fixed our issue, but I think that is a workaround

@SBelkaid
Copy link

Not sure if the await keyword used when calling aioredis.from_url is required. Could it be that?

@simon-liebehenschel
Copy link

simon-liebehenschel commented Jan 26, 2022

We migrated to aioredis 2.0

I had the same warning on aioredis=1.3.1 and Python 3.10. I mean that this is not a brand-new error.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants