コード例 #1
0
    def _create_data(self, code, mode, data):
        """Receive the data of a new task.

        Arguments:
            - code: code of the task.
            - mode: list with two values, ['register', 'has_kwargs'].
                If 'register' the task is subscribed.
                If 'has_kwargs' the data has kwargs.
            - data: list of the data of the task.
        """
        register, has_kwargs = map(int, mode)
        self.db_set(code, data, has_kwargs)
        if register:
            self._register_needed(code)
            if self.display:
                print('publish: ' + str(code_done(code)))
            self.tasks_pub.send(code_done(code))
コード例 #2
0
ファイル: sink.py プロジェクト: pyople/pyople
    def _create_data(self, code, mode, data):
        """Receive the data of a new task.

        Arguments:
            - code: code of the task.
            - mode: list with two values, ['register', 'has_kwargs'].
                If 'register' the task is subscribed.
                If 'has_kwargs' the data has kwargs.
            - data: list of the data of the task.
        """
        register, has_kwargs = map(int, mode)
        self.db_set(code, data, has_kwargs)
        if register:
            self._register_needed(code)
            if self.display:
                print('publish: ' + str(code_done(code)))
            self.tasks_pub.send(code_done(code))
コード例 #3
0
ファイル: ventilator.py プロジェクト: pyople/pyople
    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]
コード例 #4
0
ファイル: ventilator.py プロジェクト: pyople/pyople
    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]
コード例 #5
0
ファイル: redis_manager.py プロジェクト: pyople/pyople
 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))
コード例 #6
0
 def _actualize_task(self, code):
     """Send the message of done code for the task."""
     if self.display:
         print('recv resend: ' + code)
     self.tasks_pub.send(code_done(code))
コード例 #7
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))
コード例 #8
0
ファイル: sink.py プロジェクト: pyople/pyople
 def _actualize_task(self, code):
     """Send the message of done code for the task."""
     if self.display:
         print('recv resend: ' + code)
     self.tasks_pub.send(code_done(code))