better behaviour on startup in case of errors
- fix a bug then TcpServer can not start dye to address in use - report errors when restarting interfaces - increase timeout. the timeout for waiting all interfaces starting up must be higher than a potential successful startup of TcpServer, which is currently ~ 10 sec (might be reduced, but at both places) Change-Id: I88b967c4baff79fdf94f4c849dd713d2cba6fabc Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/33985 Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de> Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de> Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch> Reviewed-by: Alexander Zaft <a.zaft@fz-juelich.de>
This commit is contained in:
@@ -159,7 +159,8 @@ class TCPServer(DualStackTCPServer):
|
||||
self.detailed_errors = options.pop('detailed_errors', False)
|
||||
|
||||
self.log.info("TCPServer %s binding to port %d", name, port)
|
||||
for ntry in range(5):
|
||||
maxtry = 5
|
||||
for ntry in range(maxtry):
|
||||
try:
|
||||
DualStackTCPServer.__init__(
|
||||
self, ('', port), TCPRequestHandler,
|
||||
@@ -167,8 +168,8 @@ class TCPServer(DualStackTCPServer):
|
||||
)
|
||||
break
|
||||
except OSError as e:
|
||||
if e.args[0] == errno.EADDRINUSE: # address already in use
|
||||
# this may happen despite of allow_reuse_address
|
||||
if ntry < maxtry - 1 and e.args[0] == errno.EADDRINUSE: # address already in use
|
||||
# this may happen after restarting for a short time even with allow_reuse_address
|
||||
time.sleep(0.3 * (1 << ntry)) # max accumulated sleep time: 0.3 * 31 = 9.3 sec
|
||||
else:
|
||||
self.log.error('could not initialize TCP Server: %r', e)
|
||||
|
||||
Reference in New Issue
Block a user