From 6920b435670bd8cd7a5792580f68859c8a5906f6 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sat, 8 Dec 2018 14:28:26 +0000 Subject: [PATCH] Scale timeout with number of connections --- ipc_unix/pubsub.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ipc_unix/pubsub.py b/ipc_unix/pubsub.py index 13696e9..a2c8ce0 100644 --- a/ipc_unix/pubsub.py +++ b/ipc_unix/pubsub.py @@ -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 = []