Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
connection: add a pointer to os.getpid to ConnectionPool
This commit adds a local pointer to `os.getpid` to `ConnectionPool` class to mitigate the `AttributeError` that occurs on Python 3.13+ on interpreter exit. This is caused by the fact that interpreter calls `__del__` on variables on exit, but `os` is being destroyed before the `valkey.Valkey` instance. It could be easily reproduced with: >>> import valkey >>> r = valkey.Valkey(host="localhost", port=6379) >>> exit() Exception ignored in: <function Valkey.__del__ at 0x7f29d084e5c0> Traceback (most recent call last): File "/home/mikhail.koviazin/workspace/valkey-py-clean/valkey/client.py", line 521, in __del__ File "/home/mikhail.koviazin/workspace/valkey-py-clean/valkey/client.py", line 536, in close File "/home/mikhail.koviazin/workspace/valkey-py-clean/valkey/connection.py", line 1179, in disconnect File "/home/mikhail.koviazin/workspace/valkey-py-clean/valkey/connection.py", line 1083, in _checkpid TypeError: 'NoneType' object is not callable Having a local pointer to that function keeps `os.getpid()` accessible during interpreter shutdown. Fixes #158 Signed-off-by: Mikhail Koviazin <[email protected]>
- Loading branch information