How to use select26 - 10 common examples

To help you get started, we’ve selected a few select26 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github apple / ccs-calendarserver / kqreactor.py View on Github external
def _doWriteOrRead(self, selectable, fd, event):
        why = None
        inRead = False
        filter, flags, data, fflags = event.filter, event.flags, event.data, event.fflags
        if flags & KQ_EV_EOF and data and fflags:
            why = main.CONNECTION_LOST
        else:
            try:
                if filter == KQ_FILTER_READ:
                    inRead = True
                    why = selectable.doRead()
                if filter == KQ_FILTER_WRITE:
                    inRead = False
                    why = selectable.doWrite()
                if not selectable.fileno() == fd:
                    inRead = False
                    why = main.CONNECTION_LOST
            except:
                log.err()
                why = sys.exc_info()[1]

        if why:
            self._disconnectSelectable(selectable, why, inRead)
github apple / ccs-calendarserver / kqreactor.py View on Github external
def removeReader(self, reader):
        """
        Remove a Selectable for notification of data available to read.
        """
        fd = reader.fileno()
        if fd == -1:
            for fd, fdes in self._selectables.iteritems():
                if reader is fdes:
                    break
            else:
                return
        if fd in self._reads:
            self._reads.discard(fd)
            if fd not in self._writes:
                del self._selectables[fd]
            self._updateRegistration(fd, KQ_FILTER_READ, KQ_EV_DISABLE)
github apple / ccs-calendarserver / kqreactor.py View on Github external
def removeAll(self):
        """
        Remove all selectables, and return a list of them.
        """
        if self.waker is not None:
            self.removeReader(self.waker)
        result = self._selectables.values()
        for fd in self._reads:
            self._updateRegistration(fd, KQ_FILTER_READ, KQ_EV_DELETE)
        for fd in self._writes:
            self._updateRegistration(fd, KQ_FILTER_WRITE, KQ_EV_DELETE)
        self._reads.clear()
        self._writes.clear()
        self._selectables.clear()
        if self.waker is not None:
            self.addReader(self.waker)
        return result
github apple / ccs-calendarserver / kqreactor.py View on Github external
def addReader(self, reader):
        """
        Add a FileDescriptor for notification of data available to read.
        """
        fd = reader.fileno()
        if fd not in self._reads:
            if fd not in self._selectables:
                self._updateRegistration(fd, KQ_FILTER_READ, KQ_EV_ADD|KQ_EV_ENABLE)
                self._updateRegistration(fd, KQ_FILTER_WRITE, KQ_EV_ADD|KQ_EV_DISABLE)
                self._selectables[fd] = reader
            else:
                self._updateRegistration(fd, KQ_FILTER_READ, KQ_EV_ENABLE)
            self._reads.add(fd)
github apple / ccs-calendarserver / kqreactor.py View on Github external
def removeAll(self):
        """
        Remove all selectables, and return a list of them.
        """
        if self.waker is not None:
            self.removeReader(self.waker)
        result = self._selectables.values()
        for fd in self._reads:
            self._updateRegistration(fd, KQ_FILTER_READ, KQ_EV_DELETE)
        for fd in self._writes:
            self._updateRegistration(fd, KQ_FILTER_WRITE, KQ_EV_DELETE)
        self._reads.clear()
        self._writes.clear()
        self._selectables.clear()
        if self.waker is not None:
            self.addReader(self.waker)
        return result
github apple / ccs-calendarserver / kqreactor.py View on Github external
def _doWriteOrRead(self, selectable, fd, event):
        why = None
        inRead = False
        filter, flags, data, fflags = event.filter, event.flags, event.data, event.fflags
        if flags & KQ_EV_EOF and data and fflags:
            why = main.CONNECTION_LOST
        else:
            try:
                if filter == KQ_FILTER_READ:
                    inRead = True
                    why = selectable.doRead()
                if filter == KQ_FILTER_WRITE:
                    inRead = False
                    why = selectable.doWrite()
                if not selectable.fileno() == fd:
                    inRead = False
                    why = main.CONNECTION_LOST
            except:
                log.err()
                why = sys.exc_info()[1]

        if why:
            self._disconnectSelectable(selectable, why, inRead)
github apple / ccs-calendarserver / kqreactor.py View on Github external
def addReader(self, reader):
        """
        Add a FileDescriptor for notification of data available to read.
        """
        fd = reader.fileno()
        if fd not in self._reads:
            if fd not in self._selectables:
                self._updateRegistration(fd, KQ_FILTER_READ, KQ_EV_ADD|KQ_EV_ENABLE)
                self._updateRegistration(fd, KQ_FILTER_WRITE, KQ_EV_ADD|KQ_EV_DISABLE)
                self._selectables[fd] = reader
            else:
                self._updateRegistration(fd, KQ_FILTER_READ, KQ_EV_ENABLE)
            self._reads.add(fd)
github apple / ccs-calendarserver / kqreactor.py View on Github external
def removeWriter(self, writer):
        """
        Remove a Selectable for notification of data available to write.
        """
        fd = writer.fileno()
        if fd == -1:
            for fd, fdes in self._selectables.iteritems():
                if writer is fdes:
                    break
            else:
                return
        if fd in self._writes:
            self._writes.discard(fd)
            if fd not in self._reads:
                del self._selectables[fd]
            self._updateRegistration(fd, KQ_FILTER_WRITE, KQ_EV_DISABLE)
github apple / ccs-calendarserver / kqreactor.py View on Github external
def addWriter(self, writer):
        """
        Add a FileDescriptor for notification of data available to write.
        """
        fd = writer.fileno()
        if fd not in self._writes:
            if fd not in self._selectables:
                self._updateRegistration(fd, KQ_FILTER_WRITE, KQ_EV_ADD|KQ_EV_ENABLE)
                self._updateRegistration(fd, KQ_FILTER_READ, KQ_EV_ADD|KQ_EV_DISABLE)
                self._selectables[fd] = writer
            else:
                self._updateRegistration(fd, KQ_FILTER_WRITE, KQ_EV_ENABLE)
            self._writes.add(fd)
github apple / ccs-calendarserver / kqreactor.py View on Github external
def addReader(self, reader):
        """
        Add a FileDescriptor for notification of data available to read.
        """
        fd = reader.fileno()
        if fd not in self._reads:
            if fd not in self._selectables:
                self._updateRegistration(fd, KQ_FILTER_READ, KQ_EV_ADD|KQ_EV_ENABLE)
                self._updateRegistration(fd, KQ_FILTER_WRITE, KQ_EV_ADD|KQ_EV_DISABLE)
                self._selectables[fd] = reader
            else:
                self._updateRegistration(fd, KQ_FILTER_READ, KQ_EV_ENABLE)
            self._reads.add(fd)

select26

Backport of the new select module with epoll and kqueue interface

MIT
Latest version published 17 years ago

Package Health Score

42 / 100
Full package analysis

Similar packages