MCPcopy Create free account
hub / github.com/EasyIME/PIME / _handle_write

Method _handle_write

python/python3/tornado/iostream.py:958–994  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

956 )
957
958 def _handle_write(self) -> None:
959 while True:
960 size = len(self._write_buffer)
961 if not size:
962 break
963 assert size > 0
964 try:
965 if _WINDOWS:
966 # On windows, socket.send blows up if given a
967 # write buffer that's too large, instead of just
968 # returning the number of bytes it was able to
969 # process. Therefore we must not call socket.send
970 # with more than 128KB at a time.
971 size = 128 * 1024
972
973 num_bytes = self.write_to_fd(self._write_buffer.peek(size))
974 if num_bytes == 0:
975 break
976 self._write_buffer.advance(num_bytes)
977 self._total_write_done_index += num_bytes
978 except BlockingIOError:
979 break
980 except (socket.error, IOError, OSError) as e:
981 if not self._is_connreset(e):
982 # Broken pipe errors are usually caused by connection
983 # reset, and its better to not log EPIPE errors to
984 # minimize log spam
985 gen_log.warning("Write error on %s: %s", self.fileno(), e)
986 self.close(exc_info=e)
987 return
988
989 while self._write_futures:
990 index, future = self._write_futures[0]
991 if index > self._total_write_done_index:
992 break
993 self._write_futures.popleft()
994 future_set_result_unless_cancelled(future, None)
995
996 def _consume(self, loc: int) -> bytes:
997 # Consume loc bytes from the read buffer and return them

Callers 2

writeMethod · 0.95
_handle_eventsMethod · 0.95

Calls 7

write_to_fdMethod · 0.95
_is_connresetMethod · 0.95
filenoMethod · 0.95
closeMethod · 0.95
peekMethod · 0.80
advanceMethod · 0.80

Tested by

no test coverage detected