From: Ondrej Lichtner <olichtne(a)redhat.com>
Before calling select on provided connection/socket objects we need to
check if any of them may have been closed and need to be removed first.
The main reason for this is that a closed multiprocessing.Connection
object may be present in the list which will result in the following
select call returning with an exception. This exception doesn't indicate
which of the file objects causes the issue and selecting for "error"
file descriptors also doesn't help. As such we need to check this before
calling select.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Common/ConnectionHandler.py | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/lnst/Common/ConnectionHandler.py b/lnst/Common/ConnectionHandler.py
index 3f7f99f..a74d4a8 100644
--- a/lnst/Common/ConnectionHandler.py
+++ b/lnst/Common/ConnectionHandler.py
@@ -59,6 +59,11 @@ class ConnectionHandler(object):
return self._check_connections(connections, timeout)
def _check_connections(self, connections, timeout):
+ for c in list(connections):
+ if c.closed:
+ self.remove_connection(c)
+ connections.remove(c)
+
requests = []
try:
rl, wl, xl = select.select(connections, [], [], timeout)
--
2.26.0