Scale timeout with number of connections

This commit is contained in:
Jake Howard 2018-12-08 14:28:26 +00:00
parent 7fd83b05b9
commit 6920b43567
Signed by: jake
GPG key ID: 57AFB45680EDD477

View file

@ -4,7 +4,7 @@ import socket
import threading
import ujson
from ipc_unix.utils import read_payload, socket_has_data
from ipc_unix.utils import DEFAULT_SOCKET_READ_TIMEOUT, read_payload, socket_has_data
class Subscriber:
@ -83,7 +83,12 @@ class Publisher:
self.connections.append(new_socket)
def write(self, message: dict):
_, writable, errorable = select.select([], self.connections, [], 1)
_, writable, errorable = select.select(
[],
self.connections,
[],
DEFAULT_SOCKET_READ_TIMEOUT * len(self.connections),
)
dead_sockets = []