Exemple #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
Exemple #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
Exemple #3
0
 def add(self, fd, callback, flags, args=(), consolidate=False):
     try:
         self.poller.register(fd, flags)
     except ValueError:
         self._discard(fd)
     else:
         dest = self.readers if flags & READ else self.writers
         if consolidate:
             self.consolidate.add(fd)
             dest[fileno(fd)] = None
         else:
             dest[fileno(fd)] = callback, args
Exemple #4
0
 def add(self, fd, callback, flags, args=(), consolidate=False):
     try:
         self.poller.register(fd, flags)
     except ValueError:
         self._discard(fd)
     else:
         dest = self.readers if flags & READ else self.writers
         if consolidate:
             self.consolidate.add(fd)
             dest[fileno(fd)] = None
         else:
             dest[fileno(fd)] = callback, args
Exemple #5
0
 def add(self, fd, callback, flags, args=(), consolidate=False):
     fd = fileno(fd)
     try:
         self.poller.register(fd, flags)
     except ValueError:
         self._remove_from_loop(fd)
         raise
     else:
         dest = self.readers if flags & READ else self.writers
         if consolidate:
             self.consolidate.add(fd)
             dest[fd] = None
         else:
             dest[fd] = callback, args
Exemple #6
0
 def add(self, fd, callback, flags, args=(), consolidate=False):
     fd = fileno(fd)
     try:
         self.poller.register(fd, flags)
     except ValueError:
         self._remove_from_loop(fd)
         raise
     else:
         dest = self.readers if flags & READ else self.writers
         if consolidate:
             self.consolidate.add(fd)
             dest[fd] = None
         else:
             dest[fd] = callback, args
Exemple #7
0
 def add(self, fd, callback, flags, args=(), consolidate=False):
     print 'Adding %s to hub' % fd
     fd = fileno(fd)
     try:
         self.poller.register(fd, flags)
     except ValueError:
         self._discard(fd)
         raise
     else:
         dest = self.readers if flags & READ else self.writers
         if consolidate:
             self.consolidate.add(fd)
             dest[fd] = None
         else:
             dest[fd] = callback, args
Exemple #8
0
 def _discard(self, fd):
     fd = fileno(fd)
     self.readers.pop(fd, None)
     self.writers.pop(fd, None)
     self.consolidate.discard(fd)
Exemple #9
0
 def remove(self, fd):
     fd = fileno(fd)
     self._unregister(fd)
     self._discard(fd)
Exemple #10
0
 def _discard(self, fd):
     fd = fileno(fd)
     self.readers.pop(fd, None)
     self.writers.pop(fd, None)
     self.consolidate.discard(fd)
Exemple #11
0
 def remove(self, fd):
     fd = fileno(fd)
     self._remove_from_loop(fd)
Exemple #12
0
 def remove(self, fd):
     fd = fileno(fd)
     self._unregister(fd)
     self._discard(fd)
Exemple #13
0
 def remove(self, fd):
     fd = fileno(fd)
     self._remove_from_loop(fd)
Exemple #14
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)