Dynamic class reset state on every deserialization
还没有人认领这个 Issue。
评估
调研方向
先使用 cloudpickle.dumps 和 loads 开始复现,然后比较每次反序列化后的类身份和 classvar 值。查看链接的 Numba vendored-cloudpickle 补丁,了解提议的方向。完成的标准是,重复调用 loads(saved) 不再意外地重置现有的 Klass 状态。
由索引模型根据 Issue 内容生成。
描述
Reproducer:
# Tested with cloudpickle 1.6.0
from cloudpickle import dumps, loads
class Klass:
classvar = None
def mutator():
Klass.classvar = 100
def check():
print("checking....")
print(f" Klass.classvar [{hex(id(Klass))}] = {Klass.classvar}")
def failing_case():
print("Klass", hex(id(Klass)))
saved = dumps(Klass)
mutator()
check()
loads(saved)
check()
loads(saved)
check()
if __name__ == '__main__':
failing_case()
Prints:
Klass 0x7fc698719980
checking....
Klass.classvar [0x7fc698719980] = 100
checking....
Klass.classvar [0x7fc698719980] = None
checking....
Klass.classvar [0x7fc698719980] = None
After each loads(saved), the state in Klass is being reset unexpectedly.
This problem can appear like a tricky race condition in distributed, multi-threaded framework, such as Dask. See example https://gist.github.com/sklam/98e7c98ce909e76a3fa7904754db7bd9.
I created a patch for this in the vendored cloudpickle in Numba: https://github.com/numba/numba/pull/7388. Please let me know if there will be problems with the way I am fixing it. If it is okay, I can submit the PR here.
- 主要语言
- Python
- 星标
- 1.9k
- 派生
- 197
- 平均合并
- 1 天 10 小时
- 30 天内合并 PR
- 1
环境准备
我们还没有检查这个项目的环境配置文件。先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
cloudpipe/cloudpickle 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
cloudpipe/cloudpickle#593 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 42/100
cloudpipe/cloudpickle#595 ·
-
难度 3/5 1-2 天 新手友好度 65/100
cloudpipe/cloudpickle#592 · 2 条评论 ·
-
难度 5/5 一周以上 新手友好度 35/100
cloudpipe/cloudpickle#589 ·
-
难度 5/5 一周以上 新手友好度 20/100
cloudpipe/cloudpickle#587 ·
查看 cloudpipe/cloudpickle 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 84/100
gradio-app/gradio#13895 ·
维护者通常 1 天内回复
-
build-error
难度 2/5 1-3 小时 新手友好度 76/100
spack/spack-packages#6713 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
ActivityWatch/activitywatch#1464 · 1 个 reaction ·
维护者通常 1 天内回复
-
[Bug]: The ckg tool drops the return type of every decorated Python method in class search results未关闭
难度 2/5 1-3 小时 新手友好度 78/100
bytedance/trae-agent#483 ·
维护者通常 1 天内回复