disconnecting from the server

Lukáš Lalinský lalinsky at gmail.com
Wed Sep 27 21:21:44 BST 2006

John Arbash Meinel wrote:
> I think the problem is that we handle a different error. In the code we do:
>             try:
>                 self.accept_and_serve()
>             except socket_timeout:
>                 # just check if we're asked to stop
>                 pass
>             except socket_error, e:
>                 trace.warning("client disconnected: %s", e)
>                 pass
> I wonder what kind of exception is being raised that we aren't catching.

It's socket.error, but the block you mentioned here can't really catch it as the
exception is raised in a different thread. The code catches the error, writes an
error message and raises it again:

            while self._serve_one_request() != False:
        except Exception, e:
            stderr.write("%s terminating on exception %s\n" % (self, e))

Perhaps the extra 'raise' could be removed? There is no way to catch exceptions
between threads anyway. Or maybe it could check for the error code, and raise it
only for real errors (what's the correct way to disconnect from the server?).


More information about the bazaar mailing list