MerginMaps / MerginMaps/python-api-client
MerginProject may not get cleaned up properly
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 23
- Forks
- 12
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 7
Description
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)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating MerginProject's pygeodiff GeoDiff creation and logger-callback setup, then compare the cleanup fix in mergin-db-sync PR 79 and the related geodiff issue 190. Done means repeated MerginProject creation no longer retains the cyclic references or causes resources to grow, using the reproduction loop to verify cleanup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100