code: def next_event(self, canceller=None):
          
          d = defer.Deferred(canceller)
          
          def cb(value):
              self.remove_callback(d.callback)
              return value
          d.addBoth(cb)
          
          self.add_callback(d.callback)
          return d
docs: Returns a :class:`~defer.Deferred` that will be called back
          with the value of the next event.