Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Fix HomeServers leaking after tests that touch inbound federation
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Quah <[email protected]>
  • Loading branch information
Sean Quah committed May 18, 2023
1 parent e5b4d93 commit 3c20fd9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion synapse/util/ratelimitutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
Set,
Tuple,
)
from weakref import WeakSet

from prometheus_client.core import Counter
from typing_extensions import ContextManager
Expand Down Expand Up @@ -86,7 +87,9 @@
)


_rate_limiter_instances: Set["FederationRateLimiter"] = set()
# This must be a `WeakSet`, otherwise we indirectly hold on to entire `HomeServer`s
# during trial test runs and leak a lot of memory.
_rate_limiter_instances: Set["FederationRateLimiter"] = WeakSet()
# Protects the _rate_limiter_instances set from concurrent access
_rate_limiter_instances_lock = threading.Lock()

Expand Down

0 comments on commit 3c20fd9

Please sign in to comment.