"Alan Kennedy" <[EMAIL PROTECTED]> wrote: [snip] > def create_connection(address, timeout=sentinel): > [snip] > if timeout != sentinel: > new_socket.settimeout(timeout) > if new_socket.gettimeout() == 0: > result = new_socket.connect_ex(address) > else: > new_socket.connect(address) > result = new_socket > [snip] > > I know that this makes it all more complex, and I'm *not* saying the > new function should be modified to include these concerns. [snip]
But now the result could be either an error code OR a socket. One of the reasons to provide a timeout for the create_connection call, if I understand correctly, is to handle cases for which you don't get a response back in sufficient time. If the user provides zero as a timeout, then they may very well get an exception, which is what they should expect. Then again, even with an arbitrary timeout, an exception is possible (especially if a host is down, etc.), and hiding the exceptional condition (didn't connect in the allotted time) is a bad thing. - Josiah _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com