Skip to content

Commit 3fc64f2

Browse files
committed
Add tests
1 parent 5e9b9f9 commit 3fc64f2

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/test_pubsub.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,3 +777,22 @@ def get_msg():
777777

778778
# the timeout on the read should not cause disconnect
779779
assert is_connected()
780+
781+
782+
@pytest.mark.onlynoncluster
783+
class TestConnectionLeak:
784+
def test_connection_leak(self, r: redis.Redis):
785+
pubsub = r.pubsub()
786+
787+
def test():
788+
tid = threading.get_ident()
789+
pubsub.subscribe(f"foo{tid}")
790+
791+
threads = [threading.Thread(target=test) for _ in range(10)]
792+
for thread in threads:
793+
thread.start()
794+
795+
for thread in threads:
796+
thread.join()
797+
798+
assert r.connection_pool._created_connections == 2

0 commit comments

Comments
 (0)