[PATCH v2 3/5] tester/telnet: Only reopen once a second
chrisj at rtems.org
chrisj at rtems.org
Tue Sep 7 04:31:52 UTC 2021
From: Chris Johns <chrisj at rtems.org>
- Limit the reopen to once a second
- Make sure the socket is closed when reopening
---
tester/rt/telnet.py | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/tester/rt/telnet.py b/tester/rt/telnet.py
index 4e5e84a..919aa86 100644
--- a/tester/rt/telnet.py
+++ b/tester/rt/telnet.py
@@ -36,6 +36,7 @@ import errno
import os
import sys
import telnetlib
+import time
from rtemstoolkit import error
from rtemstoolkit import host
@@ -71,13 +72,20 @@ class tty:
return s
def _reopen(self):
+ if self.conn:
+ self.conn.close()
+ time.sleep(1)
try:
self.conn.open(self.host, self.port, self.timeout)
except IOError as ioe:
+ if self.conn:
+ self.conn.close()
raise error.general('opening telnet: %s:%d: %s' % (self.host,
self.port,
ioe))
except:
+ if self.conn:
+ self.conn.close()
raise error.general('opening telnet: %s:%d: unknown' % (self.host,
self.port))
@@ -98,7 +106,7 @@ class tty:
if ioe.errno == errno.ECONNREFUSED:
reopen = True
data = ''
- except EOFError:
+ except EOFError as ose:
reopen = True
data = ''
if reopen:
--
2.24.1
More information about the devel
mailing list