-
Notifications
You must be signed in to change notification settings - Fork 14
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
Django runserver throws AttributeError on closing #158
Comments
hi |
@amirreza8002 it's easy to reproduce: >>> from valkey.client import Valkey
>>> r = Valkey(host="127.0.0.1", port=6379)
>>> exit()
Exception ignored in: <function Valkey.__del__ at 0x7efcc1b28900>
Traceback (most recent call last):
File "/root/valkey-learning/valkey-py-6.0.2/valkey/client.py", line 521, in __del__
File "/root/valkey-learning/valkey-py-6.0.2/valkey/client.py", line 536, in close
File "/root/valkey-learning/valkey-py-6.0.2/valkey/connection.py", line 1180, in disconnect
File "/root/valkey-learning/valkey-py-6.0.2/valkey/connection.py", line 1084, in _checkpid
TypeError: 'NoneType' object is not callable
(env-3.13) [root@spyinx valkey-py-6.0.2]# just use valkey-py in a subprocess, like python shell et. |
hi since i maintain django-valkey, i would want to know if there's a problem or perhaps if i there's a fix i know about |
@spyinx I couldn't reproduce this on my machine (Linux). What setup do you have? |
@spyinx also it looks like your error is different from the one @slimadvies has |
@mkmkme same error in one place, i just use python3.13 to learn valkey-py code, when i exit python shell, it alway occurs this exception. (env-3.13) [root@spyinx valkey-py-6.0.2]# python --version
Python 3.13.0
(env-3.13) [root@spyinx valkey-py-6.0.2]# uname -a
Linux spyinx 5.10.134-15.al8.x86_64 #1 SMP Thu Jul 20 00:44:04 CST 2023 x86_64 x86_64 x86_64 GNU/Linux
(env-3.13) [root@spyinx valkey-py-6.0.2]# cat /etc/redhat-release
Alibaba Cloud Linux release 3 (Soaring Falcon)
(env-3.13) [root@spyinx valkey-py-6.0.2]# python3
Python 3.13.0 (main, Nov 22 2024, 11:00:19) [GCC 10.2.1 20200825 (Alibaba 10.2.1-3.8 2.32)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from valkey.client import Valkey
>>> r = Valkey(host="127.0.0.1", port=6379)
>>> exit()
Exception ignored in: <function Valkey.__del__ at 0x7fae26598c20>
Traceback (most recent call last):
File "/root/valkey-learning/valkey-py-6.0.2/valkey/client.py", line 521, in __del__
File "/root/valkey-learning/valkey-py-6.0.2/valkey/client.py", line 536, in close
File "/root/valkey-learning/valkey-py-6.0.2/valkey/connection.py", line 1179, in disconnect
File "/root/valkey-learning/valkey-py-6.0.2/valkey/connection.py", line 1083, in _checkpid
TypeError: 'NoneType' object is not callable
(env-3.13) [root@spyinx valkey-py-6.0.2]# |
@spyinx ah true, I stand corrected. I also was able to reproduce it with 6.0.2 from PyPI. But couldn't reproduce with current Could you try using Thanks for the info! |
Interestingly enough, it doesn't occur in |
hi
but i'd like to emphsis that i've never seen the django one |
bpython also exits cleanly, i just saw |
python 3.12.8 also doesn't error, seems like a 3.13 problem |
Thanks @amirreza8002 ! Can confirm it doesn't fail on Python 3.12. I will start investigating now and hopefully will come up with a solution soon. |
yes, only python3.13 has the same problem, i used both versions in python3.12, it's ok [root@spyinx valkey-py-6.0.2]# python3
Python 3.12.4 (main, Nov 13 2024, 10:46:13) [GCC 10.2.1 20200825 (Alibaba 10.2.1-3.8 2.32)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from valkey import __version__
>>> __version__
'6.0.2'
>>> from valkey.client import Valkey
>>> r = Valkey(host="127.0.0.1", port=6379)
>>> exit()
[root@spyinx valkey-py-6.0.2]#
[root@spyinx valkey-py]# python3
Python 3.12.4 (main, Nov 13 2024, 10:46:13) [GCC 10.2.1 20200825 (Alibaba 10.2.1-3.8 2.32)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from valkey import __version__
>>> __version__
'6.1.0b1'
>>> from valkey.client import Valkey
>>> r = Valkey(host="127.0.0.1", port=6379)
>>> exit()
[root@spyinx valkey-py]#
(env-3.13) [root@spyinx valkey-py]# pyenv activate env-3.13
(env-3.13) [root@spyinx valkey-py]# python3
Python 3.13.0 (main, Nov 22 2024, 11:00:19) [GCC 10.2.1 20200825 (Alibaba 10.2.1-3.8 2.32)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from valkey import __version__
>>> __version__
'6.1.0b1'
>>> from valkey.client import Valkey
>>> r = Valkey(host="127.0.0.1", port=6379)
>>> exit()
Exception ignored in: <function Valkey.__del__ at 0x7f0e014ac2c0>
Traceback (most recent call last):
File "/root/valkey-learning/fix2/valkey-py/valkey/client.py", line 521, in __del__
File "/root/valkey-learning/fix2/valkey-py/valkey/client.py", line 536, in close
File "/root/valkey-learning/fix2/valkey-py/valkey/connection.py", line 1179, in disconnect
File "/root/valkey-learning/fix2/valkey-py/valkey/connection.py", line 1083, in _checkpid
TypeError: 'NoneType' object is not callable
(env-3.13) [root@spyinx valkey-py]# |
Just a small note for everyone in this thread: valkey-py 6.0.2 doesn't yet officially support Python 3.13. We have 6.1.0b1 with Python 3.13 support, but clearly it is affected by the same issue. Thank you everyone for drawing attention to this, it should be fixed in stable 6.1.0 |
for what it's worth, about the issue itself, i just tested django + valkey in python3.13 and did not have this issue as refrence, my setup ( |
Yeah I'm not sure what setup @slimadvies is using, but my guess is that when we fix it for just Python subprocess, it'll be fixed for them as well. |
Thanks. This should fix it. Nice investigating. 👍 |
Got the same issue while testing the sentinel code, will have to fix it as well. |
Previous fix only handled the connections from `Valkey` class, which left classes like `Sentinel` broken because those are handled in `AbstractConnection`. Also after merging previous fix I was pointed to the place in Python standard library where the similar issue was handled by having `from os import getpid` instead of having a local object assigned to `os.getpid`. Fixes valkey-io#158 Signed-off-by: Mikhail Koviazin <[email protected]>
When closing django-admin runserver, Valkey client consistently throws an attribute exception.
This is the same issue as redis/redis-py#3014
My setup:
Macos 15.2
Python 3.13.1
Django 4.2.17
Valkey-py 6.0.2
$ django-admin runserver
December 18, 2024 - 14:31:26
Django version 4.2.17, using settings 'milieubarometer_conf.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
^CException ignored in: <function Valkey.del at 0x106c76a20>
Traceback (most recent call last):
File ".../lib/python3.13/site-packages/valkey/client.py", line 521, in del
File ".../site-packages/valkey/client.py", line 536, in close
File ".../lib/python3.13/site-packages/valkey/connection.py", line 1179, in disconnect
File ".../lib/python3.13/site-packages/valkey/connection.py", line 1083, in _checkpid
AttributeError: 'NoneType' object has no attribute 'getpid'
The text was updated successfully, but these errors were encountered: