def start_listening(self):
    '''Starts listening for incoming events on ``EventManager.address``.
    '''
    if self.__thread:
      return
    def receive():
      context = zmq.Context()
      socket = context.socket(zmq.PULL)
      socket.bind(self.address)
      while True:
        event = pickle.loads(zlib.decompress(socket.recv()))
        event_name = event['name']
        event_args = event['args']
        if self.__handlers in event_name:
          handlers = self.__handlers[event_name]
          for handler in list(handlers):
            if not handler[3]:
              handlers.remove(handler)
            try:
              if handler[2] and handler[2]._finished:
                continue
              if handler[1]:
                (lambda h: IOLoop.instance().add_callback(lambda: h[0](event_args)))(handler)
              else:
                handler[0](event_args)
            except Exception as e:
              logging.error(format_exc())
    self.__thread = Thread(target=receive)
    self.__thread.daemon = True
    self.__thread.start()
dataset/ETHPy150Open JeremyOT/Toto/toto/events.py/EventManager.start_listening/swapped operands of `in`