class_docstr: A kqueue-based event loop for BSD/Mac systems.
code: def poll(self, timeout):
      kevents = self._kqueue.control(None, 1000, timeout)
      events = {}
      for kevent in kevents:
          fd = kevent.ident
          if kevent.filter == select.KQ_FILTER_READ:
              events[fd] = events.get(fd, 0) | IOLoop.READ
          if kevent.filter == select.KQ_FILTER_WRITE:
              if kevent.flags & select.KQ_EV_EOF:
                  # If an asynchronous connection is refused, kqueue
                  # returns a write event with the EOF flag set.
                  # Turn this into an error for consistency with the
                  # other IOLoop implementations.
                  # Note that for read events, EOF may be returned before
                  # all data has been consumed from the socket buffer,
                  # so we only check for EOF on write events.
                  events[fd] = IOLoop.ERROR
              else:
                  events[fd] = events.get(fd, 0) | IOLoop.WRITE
          if kevent.flags & select.KQ_EV_ERROR:
              events[fd] = events.get(fd, 0) | IOLoop.ERROR
      return events.items()
  
file_path: catboost/contrib/python/tornado/tornado-4/tornado/platform/kqueue.py
imports: from __future__ import absolute_import, division, print_function
  import select
  from tornado.ioloop import IOLoop, PollIOLoop
label_desc: Use image node_id 8 for calling the _KQueue obj's underlying member method code with example usage: obj.poll(timeout) and returns: events