MCPcopy
hub / github.com/tornadoweb/tornado / split_fd

Method split_fd

tornado/ioloop.py:784–804  ·  view source on GitHub ↗
(
        self, fd: Union[int, _Selectable]
    )

Source from the content-addressed store, hash-verified

782 future.result()
783
784 def split_fd(
785 self, fd: Union[int, _Selectable]
786 ) -> Tuple[int, Union[int, _Selectable]]:
787 # """Returns an (fd, obj) pair from an ``fd`` parameter.
788
789 # We accept both raw file descriptors and file-like objects as
790 # input to `add_handler` and related methods. When a file-like
791 # object is passed, we must retain the object itself so we can
792 # close it correctly when the `IOLoop` shuts down, but the
793 # poller interfaces favor file descriptors (they will accept
794 # file-like objects and call ``fileno()`` for you, but they
795 # always return the descriptor itself).
796
797 # This method is provided for use by `IOLoop` subclasses and should
798 # not generally be used by application code.
799
800 # .. versionadded:: 4.0
801 # """
802 if isinstance(fd, int):
803 return fd, fd
804 return fd.fileno(), fd
805
806 def close_fd(self, fd: Union[int, _Selectable]) -> None:
807 # """Utility method to close an ``fd``.

Callers 3

add_handlerMethod · 0.80
update_handlerMethod · 0.80
remove_handlerMethod · 0.80

Calls 1

filenoMethod · 0.45

Tested by

no test coverage detected