prometheus / prometheus/client_python

Error: TypeError: expected str, bytes or os.PathLike object, not NoneType

未关闭
#1,061 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Python
星标
4.4k
派生
876
平均合并
8 天 4 小时
30 天内合并 PR
1

描述

Sometimes i get this error:

Traceback (most recent call last):
  File "/opt/homebrew/Cellar/python@3.10/3.10.15/Frameworks/Python.framework/Versions/3.10/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/opt/homebrew/Cellar/python@3.10/3.10.15/Frameworks/Python.framework/Versions/3.10/lib/python3.10/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/homebrew/lib/python3.10/site-packages/django_q/cluster.py", line 165, in __init__
    self.start()
  File "/opt/homebrew/lib/python3.10/site-packages/django_q/cluster.py", line 174, in start
    self.guard()
  File "/opt/homebrew/lib/python3.10/site-packages/django_q/cluster.py", line 315, in guard
    self.reincarnate(p)
  File "/opt/homebrew/lib/python3.10/site-packages/django_q/cluster.py", line 234, in reincarnate
    prometheus_multiprocess.mark_process_dead(process.pid)
  File "/opt/homebrew/lib/python3.10/site-packages/prometheus_client/multiprocess.py", line 169, in mark_process_dead
    for f in glob.glob(os.path.join(path, f'gauge_{mode}_{pid}.db')):
  File "/opt/homebrew/Cellar/python@3.10/3.10.15/Frameworks/Python.framework/Versions/3.10/lib/python3.10/posixpath.py", line 76, in join
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType

It happen here:

https://github.com/django-q2/django-q2/blob/337a5782d9113a6e9d058743488e7517aebb8280/django_q/cluster.py#L233-L234

When mark_process_dead is called.

Can you help me?

Thanks.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 django_q/cluster.py 第 233-234 行附近开始,跟踪对 prometheus_client.multiprocess.mark_process_dead 的调用。重现该故障,并检查为什么传递给 os.path.join 的路径是 None。确认原因,并为失败场景定义和验证行为,即视为完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
django, prometheus, python
领域
observability
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。