MerginMaps / MerginMaps/python-api-client
MerginProject may not get cleaned up properly
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 23
- 派生
- 12
- 平均合并
- 2 天 13 小时
- 30 天内合并 PR
- 7
描述
When MerginProject is created, it creates geodiff object and assigns an internal logger to geodiff. This creates a cyclic reference (pygeodiff refs MerginProject, and MerginProject refs pygeodiff) that may keep resources held, which may be a problem if MerginProject object is created many times. See also fix for this in db-sync: https://github.com/MerginMaps/mergin-db-sync/pull/79
Also somehow related: https://github.com/MerginMaps/geodiff/issues/190
Code snippet to replicate the cleanup issue:
import pygeodiff
class MerginProjectX:
def __init__(self, directory):
def _logger_callback(level, text_bytes):
self.x() # not a real function, but refs this object...
self.geodiff = pygeodiff.GeoDiff()
self.geodiff.set_logger_callback(_logger_callback)
# this will keep consuming more and more resources
for i in range(50000):
print(i)
mp = MerginProjectX("x")
#mp.geodiff = None # this helps to break ref cycle
time.sleep(0.005)
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先定位 MerginProject 的 pygeodiff GeoDiff 创建以及 logger-callback 设置,然后对比 mergin-db-sync PR 79 中的清理修复和相关的 geodiff issue 190。完成标准是:重复创建 MerginProject 不再保留循环引用,也不会导致资源增长,并使用复现循环验证清理效果。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- api
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100