Open byron-lambda opened 11 months ago
Can confirm this behaviour with version 5.0.1
with Django. I get this error when the development server restarts
Can confirm this behaviour with version 5.0.8
, Python 3.9, when running pytest
test suite opening a Redis Client in a subclass of the beam.DoFn
class, as part of its setup
method. The error is reproduced when the test suite ends and the client is closed.
I've opened https://github.com/redis/redis-py/pull/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 (https://github.com/redis/redis-py/blob/d3a3ada03e080f39144807c9fbe44876c40e0548/redis/connection.py#L226 for example)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 https://github.com/redis/redis-py/blob/d3a3ada03e080f39144807c9fbe44876c40e0548/redis/client.py#L506 which was recently introduced in https://github.com/redis/redis-py/commit/012f7cf7d2950e8241eb5705e7cdd83b09370ba4