def _generate_events(self, event):
        try:
            if not any([self._read, self._write]):
                return
            timeout = event.time_left
            if timeout < 0:
                r, w, _ = select.select(self._read, self._write, [])
            else:
                r, w, _ = select.select(self._read, self._write, [], timeout)
        except ValueError as e:
            # Possibly a file descriptor has gone negative?
            return self._preenDescriptors()
        except TypeError as e:
            # Something *totally* invalid (object w/o fileno, non-integral
            # result) was passed
            return self._preenDescriptors()
        except (SelectError, SocketError, IOError) as e:
            # select(2) encountered an error
            if e.args[0] in (0, 2):
                # windows does this if it got an empty list
                if (not self._read) and (not self._write):
                    return
                else:
                    raise
            elif e.args[0] == EINTR:
                return
            elif e.args[0] == EBADF:
                return self._preenDescriptors()
            else:
                # OK, I really don't know what's going on.  Blow up.
                raise

        for sock in w:
            if self.isWriting(sock):
                self.fire(_write(sock), self.getTarget(sock))

        for sock in r:
            if sock == self._ctrl_recv:
                self._read_ctrl()
                continue
            if self.isReading(sock):
                self.fire(_read(sock), self.getTarget(sock))
dataset/ETHPy150Open circuits/circuits/circuits/core/pollers.py/Select._generate_events/original