(url: str, timeout: float = 0.5)
| 249 | |
| 250 | |
| 251 | def redis_ping_url(url: str, timeout: float = 0.5) -> bool: |
| 252 | host_port = redis_url_host_port(url) |
| 253 | if host_port is None: |
| 254 | return False |
| 255 | host, port = host_port |
| 256 | try: |
| 257 | with socket.create_connection((host, port), timeout=timeout) as sock: |
| 258 | sock.settimeout(timeout) |
| 259 | sock.sendall(b"*1\r\n$4\r\nPING\r\n") |
| 260 | return sock.recv(16).startswith(b"+PONG") |
| 261 | except OSError: |
| 262 | return False |
| 263 | |
| 264 | |
| 265 | def truthy_env_value(value: str | None) -> bool: |
no test coverage detected