Commit 4bdeb90
Mikhail Koviazin
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 <mikhail.koviazin@aiven.io>1 parent ebdf9c9 commit 4bdeb90
1 file changed
+16
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1011 | 1011 | | |
1012 | 1012 | | |
1013 | 1013 | | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
1014 | 1028 | | |
1015 | 1029 | | |
1016 | 1030 | | |
| |||
1080 | 1094 | | |
1081 | 1095 | | |
1082 | 1096 | | |
1083 | | - | |
| 1097 | + | |
1084 | 1098 | | |
1085 | 1099 | | |
1086 | 1100 | | |
1087 | 1101 | | |
1088 | 1102 | | |
1089 | 1103 | | |
1090 | | - | |
| 1104 | + | |
1091 | 1105 | | |
1092 | 1106 | | |
1093 | 1107 | | |
| |||
0 commit comments