coleifer / irc

tinkering with a made-from-scratch irc library in python
http://irckit.readthedocs.org/
MIT License
179 stars 55 forks source link

Should IRCConnection.connect() call sys.exit() ? #9

Closed kapacuk closed 10 years ago

kapacuk commented 10 years ago

I think it would be much better just to return True or False and let the caller decide what to do if the connection was unsuccessful - retry a bit later, try another server, or indeed exit.

coleifer commented 10 years ago

The relevant code:

    def connect(self):
        """\
        Connect to the IRC server using the nickname
        """
        self._sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        try:
            self._sock.connect((self.server, self.port))
        except socket.error:
            self.logger.error('Unable to connect to %s on port %d' % (self.server, self.port), exc_info=1)
            sys.exit(1)

        self._sock_file = self._sock.makefile()
        self.register_nick()
        self.register()