kragniz / kragniz/python-etcd3

watch_prefix memory leak

Open
#1,411 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
450
Forks
194
PR merge metrics
No merged PRs in 30d

Description

**memory leak of continually calling watch_prefix() when cancel() not called**
```
import etcd3
import tracemalloc

e = etcd3.client()

for i in range(100000):
e.put('/foo/bar', b'value')

tracemalloc.start()
while 1:
snap = tracemalloc.take_snapshot()
for s in snap.statistics('filename')[:1]:
print(s)
i = 0
it, c, = e.watch_prefix('/foo', start_revision=1)
for ev in it:
i += 1
if i > 1000:
break

Contributor guide

Open the contributing guide

Research direction

Start by running the supplied tracemalloc reproduction around repeated watch_prefix('/foo', start_revision=1) calls, noting that the iterator is stopped after 1,000 events without cancel(). Trace the watch_prefix entry point and its iterator and cancellation handling; done means repeated calls no longer show unbounded memory growth when cancel() is omitted.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.