jonathanslenders / asyncio-redis

Redis client for Python asyncio (PEP 3156)
http://asyncio-redis.readthedocs.org/
Other
552 stars 74 forks source link

Connections not closing #109

Open jared-mackey opened 7 years ago

jared-mackey commented 7 years ago

It appears that connections are not being closed correctly when the connection is "lost". I first noticed this when redis stopped taking in new connections and had reached it's maximum connections and I had to restart my app.

I am not able to reliable make the protocol think that the connection is lost, however when it does it is clear that the number of connections grows. I am watching the connections with netstat | grep 6379 | wc -l on a server that only has this once instance of the app. Right after the logs print out Redis connection lost I see that it has grown by 20 connections (pool size of 5 with 4 processes).

mikekeda commented 6 years ago

@mackeyja92 Did you find any workaround? I have same problem, after first test there are no awardable connections. My workaround for now - add try-except where I'm using redis:

    try:
        await session_interface.save(request, response)
    except RuntimeError:
        pass
    try:
        rendered_page = await cache.get(key)
    except RuntimeError:
        rendered_page = None
        try:
            await cache.set(key, rendered_page)
        except RuntimeError:
            pass