refactor(connector.py): move time.sleep to the top of Connector._loop() to avoid infinite immediate retrying if data empty
This commit is contained in:
@@ -83,6 +83,7 @@ class Connector:
|
||||
self.socket.connect((self.host, self.port))
|
||||
self.socket.settimeout(self.socket_timeout)
|
||||
self.logger.info(f"[+] Connected to {self.host}:{self.port}")
|
||||
self.send_hello()
|
||||
except (
|
||||
socket.timeout,
|
||||
ConnectionRefusedError,
|
||||
@@ -131,6 +132,7 @@ class Connector:
|
||||
def _loop(self) -> None:
|
||||
self.logger.debug("Starting main loop...")
|
||||
while True:
|
||||
time.sleep(1)
|
||||
data: bytes = self.receive()
|
||||
if not data:
|
||||
continue
|
||||
@@ -140,7 +142,6 @@ class Connector:
|
||||
# self.logger.debug("[.] ACK verified")
|
||||
# else:
|
||||
# self.logger.error("[!] ACK verification failed")
|
||||
time.sleep(1)
|
||||
|
||||
def run(self) -> None:
|
||||
self.logger.debug("Running Connector...")
|
||||
|
||||
Reference in New Issue
Block a user