-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Stderr backtrace caused by redis.client.Redis.__del__
on process exit.
#3014
Comments
Can confirm this behaviour with version |
Can confirm this behaviour with version |
Client.close() may call ConnectionPool.release() or ConnectionPool.disconnect(); both methods may end up calling os.getpid() (through ConnectionPool._checkpid() or threading.Lock() (through ConnectionPool.reset()). As mentioned in the Python documentation [1], at interpreter shutdown, module globals (in this case, the os and threading module references) may be deleted or set to None before __del__() methods are called. This causes an AttributeError to be raised when trying to run e.g. os.getpid(); while the error is ignored by the interpreter, the traceback is still printed out to stderr. Closes redis#3014 [1] https://docs.python.org/3/reference/datamodel.html#object.__del__
I've opened #3397 after encountering this issue following a ddtrace update (probably due to the module loading / patching shenanigans it performs for libraries it wants to monkey-patch). Thanks @byron-lambda for opening this issue in the first place, and pointing me in the right direction ! |
Version: 5.0.1
Platform: Python 3.8.18 on Ubuntu 20.04
Description: Backtrace to stderr on process exit due to
redis.client.Redis.__del__()
Here is the trace:
Occurs due to unloaded globals being referenced in methods called in destructors on process exit. See warning in Python docs here
This can be fixed in a couple of ways:
redis.client.Redis.__del__()
as it appears has been done in many other destructors (redis-py/redis/connection.py
Line 226 in d3a3ada
redis.connection.ConnectionPool
class and call via the references. The globals that require references in areos.getpid
andchain
(fromitertools
) afaict.NOTE: It is quite hard to come up with a small piece of code to reproduce this issue as it is caused by a race in the unload order at exit. I'll try to come up with something reliable if req'd.
NOTE: The issue is triggered by
redis-py/redis/client.py
Line 506 in d3a3ada
The text was updated successfully, but these errors were encountered: