hush exception noise
This commit is contained in:
parent
9f998221da
commit
0ba01b2ce7
|
@ -151,18 +151,26 @@ def handle(skt, client_address, owner, send_handshake, expected_handshake):
|
||||||
got = b""
|
got = b""
|
||||||
# for the receiver, this includes the "go\n"
|
# for the receiver, this includes the "go\n"
|
||||||
while len(got) < len(expected_handshake):
|
while len(got) < len(expected_handshake):
|
||||||
got += skt.recv(1)
|
more = skt.recv(1)
|
||||||
|
if not more:
|
||||||
|
raise BadHandshake("disconnect after merely '%r'" % got)
|
||||||
|
got += more
|
||||||
if expected_handshake[:len(got)] != got:
|
if expected_handshake[:len(got)] != got:
|
||||||
raise BadHandshake("got '%r' want '%r'" %
|
raise BadHandshake("got '%r' want '%r'" %
|
||||||
(got, expected_handshake))
|
(got, expected_handshake))
|
||||||
print "handler negotiation finished", client_address
|
print "handler negotiation finished", client_address
|
||||||
except:
|
except Exception as e:
|
||||||
|
print "handler failed", client_address
|
||||||
try:
|
try:
|
||||||
|
# this raises socket.err(EBADF) if the socket was already closed
|
||||||
skt.shutdown(socket.SHUT_WR)
|
skt.shutdown(socket.SHUT_WR)
|
||||||
except socket.error:
|
except socket.error:
|
||||||
pass
|
pass
|
||||||
skt.close()
|
skt.close() # this appears to be idempotent
|
||||||
raise
|
# ignore socket errors, warn about coding errors
|
||||||
|
if not isinstance(e, (socket.error, socket.timeout, BadHandshake)):
|
||||||
|
raise
|
||||||
|
return
|
||||||
# owner is now responsible for the socket
|
# owner is now responsible for the socket
|
||||||
owner._negotiation_finished(skt) # note thread
|
owner._negotiation_finished(skt) # note thread
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user