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