redis-py icon indicating copy to clipboard operation
redis-py copied to clipboard

Socket error vs. OSError

Open dinoDayo opened this issue 2 years ago • 2 comments

Reference: https://github.com/redis/redis-py/blob/b7f9a4c02aeb687d4db307a63cff0fb24aaec427/redis/asyncio/connection.py#L457

TL;DR: This is a continuation of a known bug in the sync implementation of this library. I think a corresponding edit is needed for the async function definition.

I believe an additional except socket.error clause may needed in the async definition of self.disconnect. The synchronous version of the self.disconnect function had that clause added after users started reporting seeing <AbstractConnection.__del__ at HEXMEMORYLOC error messages. See conversation and resolution linked here. I have been seeing the same errors in my asynchronous implementation of this library and suspect that a PR that adds:

        except socket.error:
            pass

in line 457 of https://github.com/redis/redis-py/blob/b7f9a4c02aeb687d4db307a63cff0fb24aaec427/redis/asyncio/connection.py should address these issues. I will test locally and update once I am sure it works for my use-case.

Thank you for your time!

dinoDayo avatar Jun 25 '24 16:06 dinoDayo

I tried creating a branch and making a PR but I got a 403 response. Will update once I am sure this fix works for us, it has been deployed but will take a few days for me to be sure.

dinoDayo avatar Jun 25 '24 17:06 dinoDayo

Following up - applying this patch led to more downstream errors. These errors were helpful context into their root cause; celery does not explicitly close connections with the redis backend, but rather relies on the __del__ method during interpreter shutdown. For anyone facing similar issues, check this thread out for potential next steps in debugging. Will update if/when a stable solution is identified for my use-case.

dinoDayo avatar Jun 27 '24 15:06 dinoDayo