Exemple #1
0
 def _restore_task_clean_server_tornado(self, msg):
     """Create and register a server task received during clean mode."""
     list_code, code, address, num_output = msg
     list_code = json_loads(list_code)
     num_output = int(num_output)
     actual_data = TaskServerData(code, address, num_output, self)
     self._register_needed(list_code, actual_data)
     self.tasks_pub.send(code_resend(code))
Exemple #2
0
 def _register_needed(self, code):
     """Subscribe to the task of the code. Will receive the finish message
     and resend message."""
     if self.display:
         print('subscribe: ' + code)
     self.tasks_del.setsockopt(SUBSCRIBE, code_finish(code))
     self.tasks_sub.setsockopt(SUBSCRIBE, code_resend(code))
     self.subscribed_tasks.append(code)
Exemple #3
0
 def _restore_task_clean_server_tornado(self, msg):
     """Create and register a server task received during clean mode."""
     list_code, code, address, num_output = msg
     list_code = json_loads(list_code)
     num_output = int(num_output)
     actual_data = TaskServerData(code, address, num_output, self)
     self._register_needed(list_code, actual_data)
     self.tasks_pub.send(code_resend(code))
Exemple #4
0
 def _register_needed(self, code):
     """Subscribe to the task of the code. Will receive the finish message
     and resend message."""
     if self.display:
         print('subscribe: ' + code)
     self.tasks_del.setsockopt(SUBSCRIBE, code_finish(code))
     self.tasks_sub.setsockopt(SUBSCRIBE, code_resend(code))
     self.subscribed_tasks.append(code)
Exemple #5
0
 def _del_task(self, code):
     """Unsubscribe to the task of the code."""
     if self.display:
         print('recv del: ' + code)
     self.tasks_del.setsockopt(UNSUBSCRIBE, code)
     un_code = uncode(code)
     self.tasks_sub.setsockopt(UNSUBSCRIBE, code_resend(un_code))
     try:
         self.subscribed_tasks.remove(un_code)
     except ValueError:
         pass
Exemple #6
0
 def _del_task(self, code):
     """Unsubscribe to the task of the code."""
     if self.display:
         print('recv del: ' + code)
     self.tasks_del.setsockopt(UNSUBSCRIBE, code)
     un_code = uncode(code)
     self.tasks_sub.setsockopt(UNSUBSCRIBE, code_resend(un_code))
     try:
         self.subscribed_tasks.remove(un_code)
     except ValueError:
         pass
Exemple #7
0
 def _restore_task_clean_data_tornado(self, msg):
     """Create and register a task received during clean mode."""
     list_code, code, procedure, needed = msg
     list_code = json_loads(list_code)
     needed = json_loads(needed)
     actual_data = TaskVentilatorData(code, needed, procedure, self)
     task_needed = set(map(decode_output, needed))
     self_needed = code in task_needed
     if self_needed:
         task_needed.remove(code)
     actual_data.set_left(task_needed, self_needed)
     actual_data.update_data(len(task_needed) - len(list_code))
     self._register_needed(list_code, actual_data)
     [self.tasks_pub.send(code_resend(c)) for c in list_code]
Exemple #8
0
 def _restore_task_clean_data_tornado(self, msg):
     """Create and register a task received during clean mode."""
     list_code, code, procedure, needed = msg
     list_code = json_loads(list_code)
     needed = json_loads(needed)
     actual_data = TaskVentilatorData(code, needed, procedure, self)
     task_needed = set(map(decode_output, needed))
     self_needed = code in task_needed
     if self_needed:
         task_needed.remove(code)
     actual_data.set_left(task_needed, self_needed)
     actual_data.update_data(len(task_needed) - len(list_code))
     self._register_needed(list_code, actual_data)
     [self.tasks_pub.send(code_resend(c)) for c in list_code]
Exemple #9
0
    def _register_needed(self, needed_codes, actual_data):
        """Register the actual_data in the attribute 'tasks' the codes in
        needed_codes. Send the message to resend the message for done tasks.

        Arguments:
            needed_codes: list of needed codes to be registered.
            actual_data: instance with type TaskVentilatorData"""
        for code in needed_codes:
            code_d = code_done(code)
            if self.display:
                print('added task: ' + code_d)
            try:
                self.tasks[code_d].append(actual_data)
            except KeyError:
                if self.display:
                    print('subscribe: ' + code_d)
                self.tasks_sub.setsockopt(SUBSCRIBE, str(code_d))
                self.tasks_pub.send(code_resend(code))
                self.tasks[code_d] = [actual_data]
Exemple #10
0
    def _register_needed(self, needed_codes, actual_data):
        """Register the actual_data in the attribute 'tasks' the codes in
        needed_codes. Send the message to resend the message for done tasks.

        Arguments:
            needed_codes: list of needed codes to be registered.
            actual_data: instance with type TaskVentilatorData"""
        for code in needed_codes:
            code_d = code_done(code)
            if self.display:
                print('added task: ' + code_d)
            try:
                self.tasks[code_d].append(actual_data)
            except KeyError:
                if self.display:
                    print('subscribe: ' + code_d)
                self.tasks_sub.setsockopt(SUBSCRIBE, str(code_d))
                self.tasks_pub.send(code_resend(code))
                self.tasks[code_d] = [actual_data]
Exemple #11
0
 def _new_zero_task(self, code):
     """Subscribes to a task without procedure.
     For exemple, for tasks with a 'direct_call'."""
     self.tasks_sub.setsockopt(SUBSCRIBE, code_done(code))
     self.tasks_pub.send(code_resend(code))
Exemple #12
0
 def _new_zero_task(self, code):
     """Subscribes to a task without procedure.
     For exemple, for tasks with a 'direct_call'."""
     self.tasks_sub.setsockopt(SUBSCRIBE, code_done(code))
     self.tasks_pub.send(code_resend(code))