disconnecting from the server
John Arbash Meinel
john at arbash-meinel.com
Wed Sep 27 21:44:16 BST 2006
Lukáš Lalinský wrote:
> 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:
>
> try:
> while self._serve_one_request() != False:
> pass
> except Exception, e:
> stderr.write("%s terminating on exception %s\n" % (self, e))
> raise
>
> 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?).
>
> -Lukáš
Well, if it is in the code path that I see, '_serve_one_request()' tries
to catch all exceptions , and send False to the client if necessary.
So what about this fix:
try:
req_args = self._recv_tuple()
except socket.error, e:
mutter('got a disconnection error: %s', e)
return False
if req_args is None:
...
John
=:->
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060927/8406480d/attachment.pgp
More information about the bazaar
mailing list