Пример #1
0
 def _remove_bad(self):
     for fd in self._rfd | self._wfd | self._efd:
         try:
             _selectf([fd], [], [], 0)
         except (_selecterr, socket.error) as exc:
             if get_errno(exc) in SELECT_BAD_FD:
                 self.unregister(fd)
Пример #2
0
 def _remove_bad(self):
     for fd in self._rfd | self._wfd | self._efd:
         try:
             _selectf([fd], [], [], 0)
         except (_selecterr, socket.error) as exc:
             if get_errno(exc) in SELECT_BAD_FD:
                 self.unregister(fd)
Пример #3
0
    def _poll(self, timeout):
        try:
            read, write, error = _selectf(
                self._rfd, self._wfd, self._efd, timeout,
            )
        except (_selecterr, socket.error) as exc:
            if get_errno(exc) == errno.EINTR:
                return
            elif get_errno(exc) in SELECT_BAD_FD:
                return self._remove_bad()
            raise

        events = {}
        for fd in read:
            if not isinstance(fd, int):
                fd = fd.fileno()
            events[fd] = events.get(fd, 0) | READ
        for fd in write:
            if not isinstance(fd, int):
                fd = fd.fileno()
            events[fd] = events.get(fd, 0) | WRITE
        for fd in error:
            if not isinstance(fd, int):
                fd = fd.fileno()
            events[fd] = events.get(fd, 0) | ERR
        return list(events.items())
Пример #4
0
    def _poll(self, timeout):
        try:
            read, write, error = _selectf(
                self._rfd,
                self._wfd,
                self._efd,
                timeout,
            )
        except (_selecterr, socket.error) as exc:
            if get_errno(exc) == errno.EINTR:
                return
            elif get_errno(exc) in SELECT_BAD_FD:
                return self._remove_bad()
            raise

        events = {}
        for fd in read:
            if not isinstance(fd, int):
                fd = fd.fileno()
            events[fd] = events.get(fd, 0) | READ
        for fd in write:
            if not isinstance(fd, int):
                fd = fd.fileno()
            events[fd] = events.get(fd, 0) | WRITE
        for fd in error:
            if not isinstance(fd, int):
                fd = fd.fileno()
            events[fd] = events.get(fd, 0) | ERR
        return list(events.items())
Пример #5
0
 def _poll(self, timeout):
     try:
         read, write, error = _selectf(
             self._rfd, self._wfd, self._efd, timeout,
         )
     except (_selecterr, socket.error), exc:
         if get_errno(exc) == errno.EINTR:
             return
         elif get_errno(exc) in SELECT_BAD_FD:
             return self._remove_bad()
         raise
Пример #6
0
 def _poll(self, timeout):
     read, write, error = _selectf(self._rfd, self._wfd, self._efd, timeout)
     events = {}
     for fd in read:
         if not isinstance(fd, int):
             fd = fd.fileno()
         events[fd] = events.get(fd, 0) | READ
     for fd in write:
         if not isinstance(fd, int):
             fd = fd.fileno()
         events[fd] = events.get(fd, 0) | WRITE
     for fd in error:
         if not isinstance(fd, int):
             fd = fd.fileno()
         events[fd] = events.get(fd, 0) | ERR
     return list(events.items())
Пример #7
0
 def _poll(self, timeout):
     read, write, error = _selectf(self._rfd, self._wfd, self._efd, timeout)
     events = {}
     for fd in read:
         if not isinstance(fd, int):
             fd = fd.fileno()
         events[fd] = events.get(fd, 0) | READ
     for fd in write:
         if not isinstance(fd, int):
             fd = fd.fileno()
         events[fd] = events.get(fd, 0) | WRITE
     for fd in error:
         if not isinstance(fd, int):
             fd = fd.fileno()
         events[fd] = events.get(fd, 0) | ERR
     return events.items()