mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 09:40:20 +00:00
clean up tag map memory leak and add a mem leak regression test
This commit is contained in:
parent
34ddaa646b
commit
e0e4d56159
2 changed files with 16 additions and 0 deletions
|
@ -361,6 +361,9 @@ class EventListener:
|
|||
return
|
||||
if not future.done():
|
||||
future.set_exception(TimeoutException())
|
||||
# We need to remove it from the map even if we didn't explicitly time it out
|
||||
# Otherwise, we get a memory leak in the tag_map
|
||||
if future in self.tag_map[(tag, matcher)] and future.done():
|
||||
self.tag_map[(tag, matcher)].remove(future)
|
||||
if len(self.tag_map[(tag, matcher)]) == 0:
|
||||
del self.tag_map[(tag, matcher)]
|
||||
|
|
|
@ -98,3 +98,16 @@ async def test_post_with_incorrect_client(http_client):
|
|||
body=salt.utils.json.dumps(low),
|
||||
)
|
||||
assert exc.value.code == 400
|
||||
|
||||
|
||||
@pytest.mark.slow_test
|
||||
async def test_mem_leak_in_event_listener(http_client, salt_minion, app):
|
||||
for i in range(10):
|
||||
await http_client.fetch(
|
||||
"/minions/{}".format(salt_minion.id),
|
||||
method="GET",
|
||||
follow_redirects=False,
|
||||
)
|
||||
assert len(app.event_listener.tag_map) == 0
|
||||
assert len(app.event_listener.timeout_map) == 0
|
||||
assert len(app.event_listener.request_map) == 0
|
||||
|
|
Loading…
Add table
Reference in a new issue