~ubuntu-branches/ubuntu/utopic/txtorcon/utopic-proposed

« back to all changes in this revision

Viewing changes to txtorcon/torcontrolprotocol.py

  • Committer: Package Import Robot
  • Author(s): Jérémy Bobbio
  • Date: 2014-07-21 00:55:46 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20140721005546-vpm4xq2hfbefplbp
Tags: 0.10.1-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
461
461
 
462
462
    def remove_event_listener(self, evt, cb):
463
463
        if evt not in self.valid_events.values():
 
464
            # this lets us pass a string or a real event-object
464
465
            try:
465
466
                evt = self.valid_events[evt]
466
467
            except:
468
469
 
469
470
        evt.unlisten(cb)
470
471
        if len(evt.callbacks) == 0:
 
472
            # note there's a slight window here for an event of this
 
473
            # type to come in before the SETEVENTS succeeds; see
 
474
            # _handle_notify which explicitly ignore this case.
471
475
            del self.events[evt.name]
472
476
            self.queue_command('SETEVENTS %s' % ' '.join(self.events.keys()))
473
477
 
548
552
        if args[0] in self.events:
549
553
            self.events[args[0]].got_update(rest[len(args[0]) + 1:])
550
554
            return
551
 
 
552
 
        raise RuntimeError("Wasn't listening for event of type " + args[0])
 
555
        # not considering this an error, as there's a slight window
 
556
        # after remove_event_listener is called (so the handler is
 
557
        # deleted) but the SETEVENTS command has not yet succeeded
553
558
 
554
559
    def _maybe_issue_command(self):
555
560
        """