<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def run(self):
 """ Blocking method that run the server. """

        if self.tasks:
            logger.info('Registered tasks: %s' % ', '.join(self.tasks))
        else:
            logger.info('No tasks registered')
        logger.info('Listening on %s ...' % self.bind)
        self.socket.bind(self.bind)

        self.running = True
        self.pre_run()

        while self.running:
            msg = self.socket.recv_pyobj()

            action = msg.get('action')
            if action == 'run_task':
                if msg.get('name') not in self.tasks:
                    print(msg.get('name'))
                    print(self.tasks)
                    response = {
                        'success': False, 'exception': TaskNotFound(msg.get('name'))}
                    self.socket.send_pyobj(response)
                else:
                    task = Task(str(uuid.uuid4()), msg.get('name'), [], {})

                    if msg.get('args'):
                        task.args = msg.get('args', [])
                    if msg.get('kwargs'):
                        task.kwargs = msg.get('kwargs', {})

                    self.task_result_backend.add_task(task)

                    self.queue.put(task.id)
                    self.socket.send_pyobj({'success': True, 'task': task})
            elif action == 'get_result':
                task_id = msg.get('id')
                task = self.task_result_backend.get_task(task_id)
                if task:
                    response = {'success': True, 'task': task}
                else:
                    response = {
                        'success': False,
                        'id': task_id,
                        'exception': TaskNotFound(task_id)}
                self.socket.send_pyobj(response)
            elif action == 'wait':
                task_id = msg.get('id')
                task = self.task_result_backend.get_task(task_id)
                if task:
                    while not task.terminated:
                        task = self.task_result_backend.get_task(task_id)
                        time.sleep(1)
                    response = {'success': True, 'task': task}
                else:
                    response = {
                        'success': False,
                        'id': task_id,
                        'exception': TaskNotFound(task_id)}
                self.socket.send_pyobj(response)
            else:
                response = {'success': False, 'exception': MessageMalformed()}
                self.socket.send_pyobj(response)