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

Method _handle_events

python/python3/tornado/iostream.py:684–735  ·  view source on GitHub ↗
(self, fd: Union[int, ioloop._Selectable], events: int)

Source from the content-addressed store, hash-verified

682 raise NotImplementedError()
683
684 def _handle_events(self, fd: Union[int, ioloop._Selectable], events: int) -> None:
685 if self.closed():
686 gen_log.warning("Got events for closed stream %s", fd)
687 return
688 try:
689 if self._connecting:
690 # Most IOLoops will report a write failed connect
691 # with the WRITE event, but SelectIOLoop reports a
692 # READ as well so we must check for connecting before
693 # either.
694 self._handle_connect()
695 if self.closed():
696 return
697 if events & self.io_loop.READ:
698 self._handle_read()
699 if self.closed():
700 return
701 if events & self.io_loop.WRITE:
702 self._handle_write()
703 if self.closed():
704 return
705 if events & self.io_loop.ERROR:
706 self.error = self.get_fd_error()
707 # We may have queued up a user callback in _handle_read or
708 # _handle_write, so don't close the IOStream until those
709 # callbacks have had a chance to run.
710 self.io_loop.add_callback(self.close)
711 return
712 state = self.io_loop.ERROR
713 if self.reading():
714 state |= self.io_loop.READ
715 if self.writing():
716 state |= self.io_loop.WRITE
717 if state == self.io_loop.ERROR and self._read_buffer_size == 0:
718 # If the connection is idle, listen for reads too so
719 # we can tell if the connection is closed. If there is
720 # data in the read buffer we won't run the close callback
721 # yet anyway, so we don't need to listen in this case.
722 state |= self.io_loop.READ
723 if state != self._state:
724 assert (
725 self._state is not None
726 ), "shouldn't happen: _handle_events without self._state"
727 self._state = state
728 self.io_loop.update_handler(self.fileno(), self._state)
729 except UnsatisfiableReadError as e:
730 gen_log.info("Unsatisfiable read, closing connection: %s" % e)
731 self.close(exc_info=e)
732 except Exception as e:
733 gen_log.error("Uncaught exception, closing connection.", exc_info=True)
734 self.close(exc_info=e)
735 raise
736
737 def _read_to_buffer_loop(self) -> Optional[int]:
738 # This method is called from _handle_read and _try_inline_read.

Callers

nothing calls this directly

Calls 13

closedMethod · 0.95
_handle_connectMethod · 0.95
_handle_readMethod · 0.95
_handle_writeMethod · 0.95
get_fd_errorMethod · 0.95
readingMethod · 0.95
writingMethod · 0.95
filenoMethod · 0.95
closeMethod · 0.95
infoMethod · 0.80
errorMethod · 0.80
add_callbackMethod · 0.45

Tested by

no test coverage detected