{
    "mode": "pydoc",
    "parameter": "selectors",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/pydoc/selectors/json",
    "generated": "2026-06-02T15:05:24Z",
    "sections": {
        "NAME": {
            "content": "selectors - Selectors module.\n",
            "subsections": []
        },
        "MODULE REFERENCE": {
            "content": "https://docs.python.org/3.10/library/selectors.html\n\nThe following documentation is automatically generated from the Python\nsource files.  It may be incomplete, incorrect or include features that\nare considered implementation detail and may vary between Python\nimplementations.  When in doubt, consult the module reference at the\nlocation listed above.\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This module allows high-level and efficient I/O multiplexing, built upon the\n`select` module primitives.\n",
            "subsections": []
        },
        "CLASSES": {
            "content": "builtins.object\nBaseSelector\nbuiltins.tuple(builtins.object)\nSelectorKey\nBaseSelectorImpl(BaseSelector)\nSelectSelector\nPollLikeSelector(BaseSelectorImpl)\nEpollSelector\nPollSelector\n",
            "subsections": [
                {
                    "name": "class BaseSelector",
                    "content": "|  Selector abstract base class.\n|\n|  A selector supports registering file objects to be monitored for specific\n|  I/O events.\n|\n|  A file object is a file descriptor or any object with a `fileno()` method.\n|  An arbitrary object can be attached to the file object, which can be used\n|  for example to store context information, a callback, etc.\n|\n|  A selector can use various implementations (select(), poll(), epoll()...)\n|  depending on the platform. The default `Selector` class uses the most\n|  efficient implementation on the current platform.\n|\n|  Methods defined here:\n|\n|  enter(self)\n|\n|  exit(self, *args)\n|\n|  close(self)\n|      Close the selector.\n|\n|      This must be called to make sure that any underlying resource is freed.\n|\n|  getkey(self, fileobj)\n|      Return the key associated to a registered file object.\n|\n|      Returns:\n|      SelectorKey for this file object\n|\n|  getmap(self)\n|      Return a mapping of file objects to selector keys.\n|\n|  modify(self, fileobj, events, data=None)\n|      Change a registered file object monitored events or attached data.\n|\n|      Parameters:\n|      fileobj -- file object or file descriptor\n|      events  -- events to monitor (bitwise mask of EVENTREAD|EVENTWRITE)\n|      data    -- attached data\n|\n|      Returns:\n|      SelectorKey instance\n|\n|      Raises:\n|      Anything that unregister() or register() raises\n|\n|  register(self, fileobj, events, data=None)\n|      Register a file object.\n|\n|      Parameters:\n|      fileobj -- file object or file descriptor\n|      events  -- events to monitor (bitwise mask of EVENTREAD|EVENTWRITE)\n|      data    -- attached data\n|\n|      Returns:\n|      SelectorKey instance\n|\n|      Raises:\n|      ValueError if events is invalid\n|      KeyError if fileobj is already registered\n|      OSError if fileobj is closed or otherwise is unacceptable to\n|              the underlying system call (if a system call is made)\n|\n|      Note:\n|      OSError may or may not be raised\n|\n|  select(self, timeout=None)\n|      Perform the actual selection, until some monitored file objects are\n|      ready or a timeout expires.\n|\n|      Parameters:\n|      timeout -- if timeout > 0, this specifies the maximum wait time, in\n|                 seconds\n|                 if timeout <= 0, the select() call won't block, and will\n|                 report the currently ready file objects\n|                 if timeout is None, select() will block until a monitored\n|                 file object becomes ready\n|\n|      Returns:\n|      list of (key, events) for ready file objects\n|      `events` is a bitwise mask of EVENTREAD|EVENTWRITE\n|\n|  unregister(self, fileobj)\n|      Unregister a file object.\n|\n|      Parameters:\n|      fileobj -- file object or file descriptor\n|\n|      Returns:\n|      SelectorKey instance\n|\n|      Raises:\n|      KeyError if fileobj is not registered\n|\n|      Note:\n|      If fileobj is registered but has since been closed this does\n|      *not* raise OSError (even if the wrapped syscall does)\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n|\n|  ----------------------------------------------------------------------\n|  Data and other attributes defined here:\n|\n|  abstractmethods = frozenset({'getmap', 'register', 'select', 'unr...\n\nDefaultSelector = class EpollSelector(PollLikeSelector)\n|  Epoll-based selector.\n|\n|  Method resolution order:\n|      EpollSelector\n|      PollLikeSelector\n|      BaseSelectorImpl\n|      BaseSelector\n|      builtins.object\n|\n|  Methods defined here:\n|\n|  close(self)\n|      Close the selector.\n|\n|      This must be called to make sure that any underlying resource is freed.\n|\n|  fileno(self)\n|\n|  select(self, timeout=None)\n|      Perform the actual selection, until some monitored file objects are\n|      ready or a timeout expires.\n|\n|      Parameters:\n|      timeout -- if timeout > 0, this specifies the maximum wait time, in\n|                 seconds\n|                 if timeout <= 0, the select() call won't block, and will\n|                 report the currently ready file objects\n|                 if timeout is None, select() will block until a monitored\n|                 file object becomes ready\n|\n|      Returns:\n|      list of (key, events) for ready file objects\n|      `events` is a bitwise mask of EVENTREAD|EVENTWRITE\n|\n|  ----------------------------------------------------------------------\n|  Data and other attributes defined here:\n|\n|  abstractmethods = frozenset()\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from PollLikeSelector:\n|\n|  init(self)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  modify(self, fileobj, events, data=None)\n|      Change a registered file object monitored events or attached data.\n|\n|      Parameters:\n|      fileobj -- file object or file descriptor\n|      events  -- events to monitor (bitwise mask of EVENTREAD|EVENTWRITE)\n|      data    -- attached data\n|\n|      Returns:\n|      SelectorKey instance\n|\n|      Raises:\n|      Anything that unregister() or register() raises\n|\n|  register(self, fileobj, events, data=None)\n|      Register a file object.\n|\n|      Parameters:\n|      fileobj -- file object or file descriptor\n|      events  -- events to monitor (bitwise mask of EVENTREAD|EVENTWRITE)\n|      data    -- attached data\n|\n|      Returns:\n|      SelectorKey instance\n|\n|      Raises:\n|      ValueError if events is invalid\n|      KeyError if fileobj is already registered\n|      OSError if fileobj is closed or otherwise is unacceptable to\n|              the underlying system call (if a system call is made)\n|\n|      Note:\n|      OSError may or may not be raised\n|\n|  unregister(self, fileobj)\n|      Unregister a file object.\n|\n|      Parameters:\n|      fileobj -- file object or file descriptor\n|\n|      Returns:\n|      SelectorKey instance\n|\n|      Raises:\n|      KeyError if fileobj is not registered\n|\n|      Note:\n|      If fileobj is registered but has since been closed this does\n|      *not* raise OSError (even if the wrapped syscall does)\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from BaseSelectorImpl:\n|\n|  getmap(self)\n|      Return a mapping of file objects to selector keys.\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from BaseSelector:\n|\n|  enter(self)\n|\n|  exit(self, *args)\n|\n|  getkey(self, fileobj)\n|      Return the key associated to a registered file object.\n|\n|      Returns:\n|      SelectorKey for this file object\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors inherited from BaseSelector:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n"
                },
                {
                    "name": "class EpollSelector",
                    "content": "|  Epoll-based selector.\n|\n|  Method resolution order:\n|      EpollSelector\n|      PollLikeSelector\n|      BaseSelectorImpl\n|      BaseSelector\n|      builtins.object\n|\n|  Methods defined here:\n|\n|  close(self)\n|      Close the selector.\n|\n|      This must be called to make sure that any underlying resource is freed.\n|\n|  fileno(self)\n|\n|  select(self, timeout=None)\n|      Perform the actual selection, until some monitored file objects are\n|      ready or a timeout expires.\n|\n|      Parameters:\n|      timeout -- if timeout > 0, this specifies the maximum wait time, in\n|                 seconds\n|                 if timeout <= 0, the select() call won't block, and will\n|                 report the currently ready file objects\n|                 if timeout is None, select() will block until a monitored\n|                 file object becomes ready\n|\n|      Returns:\n|      list of (key, events) for ready file objects\n|      `events` is a bitwise mask of EVENTREAD|EVENTWRITE\n|\n|  ----------------------------------------------------------------------\n|  Data and other attributes defined here:\n|\n|  abstractmethods = frozenset()\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from PollLikeSelector:\n|\n|  init(self)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  modify(self, fileobj, events, data=None)\n|      Change a registered file object monitored events or attached data.\n|\n|      Parameters:\n|      fileobj -- file object or file descriptor\n|      events  -- events to monitor (bitwise mask of EVENTREAD|EVENTWRITE)\n|      data    -- attached data\n|\n|      Returns:\n|      SelectorKey instance\n|\n|      Raises:\n|      Anything that unregister() or register() raises\n|\n|  register(self, fileobj, events, data=None)\n|      Register a file object.\n|\n|      Parameters:\n|      fileobj -- file object or file descriptor\n|      events  -- events to monitor (bitwise mask of EVENTREAD|EVENTWRITE)\n|      data    -- attached data\n|\n|      Returns:\n|      SelectorKey instance\n|\n|      Raises:\n|      ValueError if events is invalid\n|      KeyError if fileobj is already registered\n|      OSError if fileobj is closed or otherwise is unacceptable to\n|              the underlying system call (if a system call is made)\n|\n|      Note:\n|      OSError may or may not be raised\n|\n|  unregister(self, fileobj)\n|      Unregister a file object.\n|\n|      Parameters:\n|      fileobj -- file object or file descriptor\n|\n|      Returns:\n|      SelectorKey instance\n|\n|      Raises:\n|      KeyError if fileobj is not registered\n|\n|      Note:\n|      If fileobj is registered but has since been closed this does\n|      *not* raise OSError (even if the wrapped syscall does)\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from BaseSelectorImpl:\n|\n|  getmap(self)\n|      Return a mapping of file objects to selector keys.\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from BaseSelector:\n|\n|  enter(self)\n|\n|  exit(self, *args)\n|\n|  getkey(self, fileobj)\n|      Return the key associated to a registered file object.\n|\n|      Returns:\n|      SelectorKey for this file object\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors inherited from BaseSelector:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n"
                },
                {
                    "name": "class PollSelector",
                    "content": "|  Poll-based selector.\n|\n|  Method resolution order:\n|      PollSelector\n|      PollLikeSelector\n|      BaseSelectorImpl\n|      BaseSelector\n|      builtins.object\n|\n|  Data and other attributes defined here:\n|\n|  abstractmethods = frozenset()\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from PollLikeSelector:\n|\n|  init(self)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  modify(self, fileobj, events, data=None)\n|      Change a registered file object monitored events or attached data.\n|\n|      Parameters:\n|      fileobj -- file object or file descriptor\n|      events  -- events to monitor (bitwise mask of EVENTREAD|EVENTWRITE)\n|      data    -- attached data\n|\n|      Returns:\n|      SelectorKey instance\n|\n|      Raises:\n|      Anything that unregister() or register() raises\n|\n|  register(self, fileobj, events, data=None)\n|      Register a file object.\n|\n|      Parameters:\n|      fileobj -- file object or file descriptor\n|      events  -- events to monitor (bitwise mask of EVENTREAD|EVENTWRITE)\n|      data    -- attached data\n|\n|      Returns:\n|      SelectorKey instance\n|\n|      Raises:\n|      ValueError if events is invalid\n|      KeyError if fileobj is already registered\n|      OSError if fileobj is closed or otherwise is unacceptable to\n|              the underlying system call (if a system call is made)\n|\n|      Note:\n|      OSError may or may not be raised\n|\n|  select(self, timeout=None)\n|      Perform the actual selection, until some monitored file objects are\n|      ready or a timeout expires.\n|\n|      Parameters:\n|      timeout -- if timeout > 0, this specifies the maximum wait time, in\n|                 seconds\n|                 if timeout <= 0, the select() call won't block, and will\n|                 report the currently ready file objects\n|                 if timeout is None, select() will block until a monitored\n|                 file object becomes ready\n|\n|      Returns:\n|      list of (key, events) for ready file objects\n|      `events` is a bitwise mask of EVENTREAD|EVENTWRITE\n|\n|  unregister(self, fileobj)\n|      Unregister a file object.\n|\n|      Parameters:\n|      fileobj -- file object or file descriptor\n|\n|      Returns:\n|      SelectorKey instance\n|\n|      Raises:\n|      KeyError if fileobj is not registered\n|\n|      Note:\n|      If fileobj is registered but has since been closed this does\n|      *not* raise OSError (even if the wrapped syscall does)\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from BaseSelectorImpl:\n|\n|  close(self)\n|      Close the selector.\n|\n|      This must be called to make sure that any underlying resource is freed.\n|\n|  getmap(self)\n|      Return a mapping of file objects to selector keys.\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from BaseSelector:\n|\n|  enter(self)\n|\n|  exit(self, *args)\n|\n|  getkey(self, fileobj)\n|      Return the key associated to a registered file object.\n|\n|      Returns:\n|      SelectorKey for this file object\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors inherited from BaseSelector:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n"
                },
                {
                    "name": "class SelectSelector",
                    "content": "|  Select-based selector.\n|\n|  Method resolution order:\n|      SelectSelector\n|      BaseSelectorImpl\n|      BaseSelector\n|      builtins.object\n|\n|  Methods defined here:\n|\n|  init(self)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  register(self, fileobj, events, data=None)\n|      Register a file object.\n|\n|      Parameters:\n|      fileobj -- file object or file descriptor\n|      events  -- events to monitor (bitwise mask of EVENTREAD|EVENTWRITE)\n|      data    -- attached data\n|\n|      Returns:\n|      SelectorKey instance\n|\n|      Raises:\n|      ValueError if events is invalid\n|      KeyError if fileobj is already registered\n|      OSError if fileobj is closed or otherwise is unacceptable to\n|              the underlying system call (if a system call is made)\n|\n|      Note:\n|      OSError may or may not be raised\n|\n|  select(self, timeout=None)\n|      Perform the actual selection, until some monitored file objects are\n|      ready or a timeout expires.\n|\n|      Parameters:\n|      timeout -- if timeout > 0, this specifies the maximum wait time, in\n|                 seconds\n|                 if timeout <= 0, the select() call won't block, and will\n|                 report the currently ready file objects\n|                 if timeout is None, select() will block until a monitored\n|                 file object becomes ready\n|\n|      Returns:\n|      list of (key, events) for ready file objects\n|      `events` is a bitwise mask of EVENTREAD|EVENTWRITE\n|\n|  unregister(self, fileobj)\n|      Unregister a file object.\n|\n|      Parameters:\n|      fileobj -- file object or file descriptor\n|\n|      Returns:\n|      SelectorKey instance\n|\n|      Raises:\n|      KeyError if fileobj is not registered\n|\n|      Note:\n|      If fileobj is registered but has since been closed this does\n|      *not* raise OSError (even if the wrapped syscall does)\n|\n|  ----------------------------------------------------------------------\n|  Data and other attributes defined here:\n|\n|  abstractmethods = frozenset()\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from BaseSelectorImpl:\n|\n|  close(self)\n|      Close the selector.\n|\n|      This must be called to make sure that any underlying resource is freed.\n|\n|  getmap(self)\n|      Return a mapping of file objects to selector keys.\n|\n|  modify(self, fileobj, events, data=None)\n|      Change a registered file object monitored events or attached data.\n|\n|      Parameters:\n|      fileobj -- file object or file descriptor\n|      events  -- events to monitor (bitwise mask of EVENTREAD|EVENTWRITE)\n|      data    -- attached data\n|\n|      Returns:\n|      SelectorKey instance\n|\n|      Raises:\n|      Anything that unregister() or register() raises\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from BaseSelector:\n|\n|  enter(self)\n|\n|  exit(self, *args)\n|\n|  getkey(self, fileobj)\n|      Return the key associated to a registered file object.\n|\n|      Returns:\n|      SelectorKey for this file object\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors inherited from BaseSelector:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n"
                },
                {
                    "name": "class SelectorKey",
                    "content": "|  SelectorKey(fileobj, fd, events, data)\n|\n|  SelectorKey(fileobj, fd, events, data)\n|\n|  Object used to associate a file object to its backing\n|  file descriptor, selected event mask, and attached data.\n|\n|  Method resolution order:\n|      SelectorKey\n|      builtins.tuple\n|      builtins.object\n|\n|  Methods defined here:\n|\n|  getnewargs(self)\n|      Return self as a plain tuple.  Used by copy and pickle.\n|\n|  repr(self)\n|      Return a nicely formatted representation string\n|\n|  asdict(self)\n|      Return a new dict which maps field names to their values.\n|\n|  replace(self, /, kwds)\n|      Return a new SelectorKey object replacing specified fields with new values\n|\n|  ----------------------------------------------------------------------\n|  Class methods defined here:\n|\n|  make(iterable) from builtins.type\n|      Make a new SelectorKey object from a sequence or iterable\n|\n|  ----------------------------------------------------------------------\n|  Static methods defined here:\n|\n|  new(cls, fileobj, fd, events, data)\n|      Create new instance of SelectorKey(fileobj, fd, events, data)\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  fileobj\n|      File object registered.\n|\n|  fd\n|      Underlying file descriptor.\n|\n|  events\n|      Events that must be waited for on this file object.\n|\n|  data\n|      Optional opaque data associated to this file object.\n|      For example, this could be used to store a per-client session ID.\n|\n|  ----------------------------------------------------------------------\n|  Data and other attributes defined here:\n|\n|  matchargs = ('fileobj', 'fd', 'events', 'data')\n|\n|  fielddefaults = {}\n|\n|  fields = ('fileobj', 'fd', 'events', 'data')\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from builtins.tuple:\n|\n|  add(self, value, /)\n|      Return self+value.\n|\n|  contains(self, key, /)\n|      Return key in self.\n|\n|  eq(self, value, /)\n|      Return self==value.\n|\n|  ge(self, value, /)\n|      Return self>=value.\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  getitem(self, key, /)\n|      Return self[key].\n|\n|  gt(self, value, /)\n|      Return self>value.\n|\n|  hash(self, /)\n|      Return hash(self).\n|\n|  iter(self, /)\n|      Implement iter(self).\n|\n|  le(self, value, /)\n|      Return self<=value.\n|\n|  len(self, /)\n|      Return len(self).\n|\n|  lt(self, value, /)\n|      Return self<value.\n|\n|  mul(self, value, /)\n|      Return self*value.\n|\n|  ne(self, value, /)\n|      Return self!=value.\n|\n|  rmul(self, value, /)\n|      Return value*self.\n|\n|  count(self, value, /)\n|      Return number of occurrences of value.\n|\n|  index(self, value, start=0, stop=9223372036854775807, /)\n|      Return first index of value.\n|\n|      Raises ValueError if the value is not present.\n|\n|  ----------------------------------------------------------------------\n|  Class methods inherited from builtins.tuple:\n|\n|  classgetitem(...) from builtins.type\n|      See PEP 585\n"
                }
            ]
        },
        "DATA": {
            "content": "EVENTREAD = 1\nEVENTWRITE = 2\n",
            "subsections": []
        },
        "FILE": {
            "content": "/usr/lib/python3.10/selectors.py\n\n",
            "subsections": []
        }
    },
    "summary": "selectors - Selectors module.",
    "flags": [],
    "examples": [],
    "see_also": []
}