fix binary backoff, add backoff for minecraft wrapper connection
This commit is contained in:
parent
52ad431877
commit
6f34ca0b39
|
@ -121,8 +121,8 @@ class socket_util(object):
|
|||
|
||||
class MinecraftWrapper(socket_util):
|
||||
def __init__(self, command, host, port):
|
||||
super().__init__(host, port)
|
||||
self.logger = LOG.getChild("MinecraftWrapper")
|
||||
super().__init__(host, port)
|
||||
self.logger.debug(command)
|
||||
self.command = command
|
||||
self.logger.info("Starting Wrapper Polling Thread")
|
||||
|
@ -134,7 +134,22 @@ class MinecraftWrapper(socket_util):
|
|||
def socket_reset(self):
|
||||
super().socket_reset()
|
||||
self.logger.debug("Connecting to {}:{}".format(self.host, self.port))
|
||||
backoff = 1
|
||||
while True:
|
||||
try:
|
||||
self.soc.connect((self.host, self.port))
|
||||
break
|
||||
except OSError as e:
|
||||
if e.errno == 111:
|
||||
LOG.warning(
|
||||
"Connection refused by {}:{}, trying again in {} seconds".format(
|
||||
self.host, self.port, backoff
|
||||
)
|
||||
)
|
||||
time.sleep(backoff)
|
||||
backoff *= 2
|
||||
else:
|
||||
raise e
|
||||
self.logger.info("Socket Connected")
|
||||
|
||||
def exe_mc(self):
|
||||
|
@ -216,8 +231,8 @@ class MinecraftServerBridge(socket_util):
|
|||
def socket_reset(self):
|
||||
super().socket_reset()
|
||||
LOG.info("Server Binding to " + self.host + " " + str(self.port))
|
||||
while True:
|
||||
backoff = 1
|
||||
while True:
|
||||
try:
|
||||
self.soc.bind((self.host, self.port))
|
||||
break
|
||||
|
|
Loading…
Reference in New Issue