Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileNotFoundError in Transport.attempt_connection causes infinite loop #439

Open
tales-aparecida opened this issue Nov 21, 2024 · 0 comments

Comments

@tales-aparecida
Copy link

Hi, thanks for the great library!

It seems #438 introduced a small bug.

        while self.running and self.socket is None and (connect_count < self.__reconnect_attempts_max or
                                                        self.__reconnect_attempts_max == -1):
            for host_and_port in self.__host_and_ports:
                try:
                    ...
+                except FileNotFoundError as err:
+                    logging.error("Could not find file %s", err.filename)
+                    self.socket = None
+                    break
                except (OSError, AssertionError):
                    self.socket = None
                    connect_count += 1
                    logging.warning("could not connect to host %s, port %s", host_and_port[0], host_and_port[1],
                                    exc_info=logging.verbose)

Since we are not updating the connect_count and the break is jumping out of the for into the while loop, if for some reason we hit that exception, we will keep retrying until the file exists, which might never happen.

It looks like we need either connect_count += 1, or we could do connect_count = self.__reconnect_attempts_max if we don't think it's a recoverable exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant