def _write(self, length):
# we need to write all the data but it's a non-blocking socket
# so loop until it's all written eating EAGAIN exceptions
data=self.netbuf_out_mv
written=0
while written < length:
try:
written += self.sock_write(data[written:length])
except OSError as e:
if len(e.args) > 0:
if e.args[0] == errno.EAGAIN:
# can't write yet, try again
pass
elif e.args[0] == errno.ECONNRESET: # connection closed
return # we are done: TODO: error?
else:
raise
else:
# something else...propagate the exception
raise
评论列表
文章目录