def run(self):
        """Implementation of the Threading run method. This methods waits on
        the tasks queue to get messages from the transport layer and then calls
        the call_method. It then waits for a response to put into the publish
        queue before waiting for a new task to come.
        """

        self.logger.debug("Controller started.")

        response = {}
        while True:
            task = self.tq.get()
            if task == "stop":
                break
            try:
                response = self.call_method(task.sender, task.body)

            except ResourceException as err:
                self.logger.error("%s" % err)

                if response.get('status'):
                    del response['status']
                response['error'] = '%s' % err

            except Exception:
                self.logger.debug('{0}'.format(traceback.format_exc()))

            finally:
                self.pq.put(AmqpTask(response, headers=task.headers))
dataset/ETHPy150Open comodit/synapse-agent/synapse/controller.py/Controller.run/original