Blame SOURCES/bz1470813-fencing-3-make-timeout-0-mean-forever.patch

e15206
From 4cf6887e98c712b99f741dbfe54932c60e93741b Mon Sep 17 00:00:00 2001
e15206
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
e15206
Date: Tue, 3 Nov 2020 14:30:12 +0100
e15206
Subject: [PATCH] fencing: fix to make timeout(s)=0 be treated as forever for
e15206
 agents using pexpect
e15206
e15206
---
e15206
 lib/fencing.py.py | 7 +++++--
e15206
 1 file changed, 5 insertions(+), 2 deletions(-)
e15206
e15206
diff --git a/lib/fencing.py.py b/lib/fencing.py.py
e15206
index 4639a9a5..fa34f13a 100644
e15206
--- a/lib/fencing.py.py
e15206
+++ b/lib/fencing.py.py
e15206
@@ -500,10 +500,13 @@ def __init__(self, options, command, **kwargs):
e15206
 		self.opt = options
e15206
 
e15206
 	def log_expect(self, pattern, timeout):
e15206
-		result = self.expect(pattern, timeout)
e15206
+		result = self.expect(pattern, timeout if timeout != 0 else None)
e15206
 		logging.debug("Received: %s", self.before + self.after)
e15206
 		return result
e15206
 
e15206
+	def read_nonblocking(self, size, timeout):
e15206
+		return pexpect.spawn.read_nonblocking(self, size=100, timeout=timeout if timeout != 0 else None)
e15206
+
e15206
 	def send(self, message):
e15206
 		logging.debug("Sent: %s", message)
e15206
 		return pexpect.spawn.send(self, message)
e15206
@@ -516,7 +519,7 @@ def frun(command, timeout=30, withexitstatus=False, events=None,
e15206
 	 extra_args=None, logfile=None, cwd=None, env=None, **kwargs):
e15206
 	if sys.version_info[0] > 2:
e15206
 		kwargs.setdefault('encoding', 'utf-8')
e15206
-	return pexpect.run(command, timeout=timeout,
e15206
+	return pexpect.run(command, timeout=timeout if timeout != 0 else None,
e15206
 			   withexitstatus=withexitstatus, events=events,
e15206
 			   extra_args=extra_args, logfile=logfile, cwd=cwd,
e15206
 			   env=env, **kwargs)