feat(api): send ping while the connection is idle

To keep the connection alive and avoid being closed.
This commit is contained in:
QuantumGhost
2026-01-14 10:25:13 +08:00
parent 9c287ee0ae
commit 8e0e5d2974
2 changed files with 10 additions and 3 deletions

View File

@ -162,7 +162,7 @@ class RedisSubscriptionBase(Subscription):
self._start_if_needed()
return iter(self._message_iterator())
def receive(self, timeout: float | None = None) -> bytes | None:
def receive(self, timeout: float | None = 0.1) -> bytes | None:
"""Receive the next message from the subscription."""
if self._closed.is_set():
raise SubscriptionClosedError(f"The Redis {self._get_subscription_type()} subscription is closed")