Skip to content

Commit fa27fe9

Browse files
committed
Add tests
1 parent 5e9b9f9 commit fa27fe9

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/test_pubsub.py

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

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

0 commit comments

Comments
 (0)