redis - redis.exceptions.DataError:类型无效的输入:'NoneType'。先转换为字节、字符串或数字
问题描述
我最近开始使用 Redis 和 RQ 来运行后台进程。我构建了一个 Dash 应用程序,它在 Heroku 上运行良好,并且过去也可以在本地运行。最近,我尝试再次在本地测试同一个应用程序,但我不断收到以下错误 - 尽管我使用的是 Heroku 上托管的完全相同的代码:
redis.exceptions.DataError: Invalid input of type: 'NoneType'. Convert to a byte, string or number first.
在 Ubuntu 18.04 上的 requirements.txt 和虚拟环境中,我有 redis v.3.0.1,rq 0.13.0
当我在终端上运行 redis-server 时,我看到使用了 Redis 4.0.9(这也让我感到困惑)。
我试图谷歌两天寻找解决方案无济于事。
有没有人知道可能发生了什么以及如何解决这个错误?
这是完整的相关回溯:
File "/home/tom/dashenv/pb101_models/pages/cumulative_culture.py", line 1026, in stop_or_start_update
job = q.fetch_job(job_id)
File "/home/tom/dashenv/dash/lib/python3.6/site-packages/rq/queue.py", line 142, in fetch_job
self.remove(job_id)
File "/home/tom/dashenv/dash/lib/python3.6/site-packages/rq/queue.py", line 186, in remove
return self.connection.lrem(self.key, 1, job_id)
File "/home/tom/dashenv/dash/lib/python3.6/site-packages/redis/client.py", line 1580, in lrem
return self.execute_command('LREM', name, count, value)
File "/home/tom/dashenv/dash/lib/python3.6/site-packages/redis/client.py", line 754, in execute_command
connection.send_command(*args)
File "/home/tom/dashenv/dash/lib/python3.6/site-packages/redis/connection.py", line 619, in send_command
self.send_packed_command(self.pack_command(*args))
File "/home/tom/dashenv/dash/lib/python3.6/site-packages/redis/connection.py", line 659, in pack_command
for arg in imap(self.encoder.encode, args):
File "/home/tom/dashenv/dash/lib/python3.6/site-packages/redis/connection.py", line 124, in encode
"byte, string or number first." % typename)
redis.exceptions.DataError: Invalid input of type: 'NoneType'. Convert to a byte, string or number first.
提前感谢您的任何建议/提示。
一切顺利,汤姆
解决方案
检查此链接:redis 3.0 它说 redis-py 不再接受 NoneType
推荐阅读
- python - 如何从分割掩码中找到 IoU?
- woocommerce - 在 Woocommerce 结帐中动态更新费用
- python - Python:仅保留最后 n 个插入键的字典
- javascript - 如何从 React 发送表单数据以表达
- python - 在 ubuntu 16.04 上使用 nginx 和 uwsgi 部署 django 项目时,nginx 无法正确提供文件
- java - 为什么 @Required 被 Spring 忽略?
- python - 使用列表理解修改字典列表
- c# - 从 Windows 窗体将值插入 SQL 数据库时出现不正确的语法错误
- wordpress - 如何将隐私政策页面与接受复选框上的标签文本链接?
- reactjs - 使用 AWS Cognito 对用户进行身份验证时出现网络错误