Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
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)