Пример #1
0
 def _callback_for(self, fd, flag, *default):
     try:
         if flag & READ:
             return self.readers[fileno(fd)]
         if flag & WRITE:
             return self.writers[fileno(fd)]
     except KeyError:
         if default:
             return default[0]
         raise
Пример #2
0
 def _callback_for(self, fd, flag, *default):
     try:
         if flag & READ:
             return self.readers[fileno(fd)]
         if flag & WRITE:
             return self.writers[fileno(fd)]
     except KeyError:
         if default:
             return default[0]
         raise
Пример #3
0
 def _add(self, fd, cb, flags):
     #if flags & WRITE:
     #    ex = self.writers.get(fd)
     #    if ex and ex.__name__ == '_write_job':
     #        assert not ex.gi_frame or ex.gi_frame == -1
     self.poller.register(fd, flags)
     (self.readers if flags & READ else self.writers)[fileno(fd)] = cb
Пример #4
0
 def _add(self, fd, cb, flags):
     #if flags & WRITE:
     #    ex = self.writers.get(fd)
     #    if ex and ex.__name__ == '_write_job':
     #        assert not ex.gi_frame or ex.gi_frame == -1
     self.poller.register(fd, flags)
     (self.readers if flags & READ else self.writers)[fileno(fd)] = cb
Пример #5
0
 def _discard(self, fd):
     fd = fileno(fd)
     self.readers.pop(fd, None)
     self.writers.pop(fd, None)
     self.consolidate.discard(fd)
Пример #6
0
 def remove(self, fd):
     fd = fileno(fd)
     self._unregister(fd)
     self._discard(fd)
Пример #7
0
 def _discard(self, fd):
     fd = fileno(fd)
     self.readers.pop(fd, None)
     self.writers.pop(fd, None)
Пример #8
0
 def remove(self, fd):
     fd = fileno(fd)
     self._unregister(fd)
     self._discard(fd)
Пример #9
0
 def _add(self, fd, cb, flags):
     self.poller.register(fd, flags)
     (self.readers if flags & READ else self.writers)[fileno(fd)] = cb
Пример #10
0
 def _add(self, fd, cb, flags, consolidate=False):
     self.poller.register(fd, flags)
     (self.readers if flags & READ else self.writers)[fileno(fd)] = cb
     if consolidate:
         self.consolidate.add(fd)
Пример #11
0
 def remove_coro(self, fds):
     for fd in maybe_list(fds, None):
         self.coros.pop(fileno(fd), None)
Пример #12
0
 def add_coro(self, fds, coro, flags):
     for fd in (fileno(f) for f in maybe_list(fds, None)):
         self._add(fd, self.trampoline, flags)
         self.coros[fd] = coro