<commit_before>import types

import synapse.common as s_common
from synapse.eventbus import EventBus

class Task(EventBus):
    '''
    A cancelable Task abstraction which operates much like a Future
    but with some additional features.
    '''
    def __init__(self, iden=None):

        EventBus.__init__(self)

        if iden is None:
            iden = s_common.guid()

        self.info = {}
        self.iden = iden

        self.on('task:fini', self._onTaskFini)

    def _onTaskFini(self, mesg):

        retn = mesg[1].get('retn')
        if retn is not None:
            self.fire('task:retn', retn=retn)

        self.fini()

    def get(self, prop, defval=None):
        '''
        Get a value from the info dict for the task.
        Args:
            prop (str): The name of the info value.
            defval (obj):   The default value to return if not found

        Returns:
            (obj):  The object from the info dict (or None)
        '''
        return self.info.get(prop, defval)

    def set(self, prop, valu):
        '''
        Set a value in the info dict for the task.

        Args:
            prop (str): The name of the info dict value
            valu (obj): The value to set in the info dict
        '''
        self.info[prop] = valu<commit_msg>added task iden to final task:retn event<commit_after>import types

import synapse.common as s_common
from synapse.eventbus import EventBus

class Task(EventBus):
    '''
    A cancelable Task abstraction which operates much like a Future
    but with some additional features.
    '''
    def __init__(self, iden=None):

        EventBus.__init__(self)

        if iden is None:
            iden = s_common.guid()

        self.info = {}
        self.iden = iden

        self.on('task:fini', self._onTaskFini)

    def _onTaskFini(self, mesg):

        retn = mesg[1].get('retn')
        if retn is not None:
            self.fire('task:retn', task=self.iden, retn=retn)

        self.fini()

    def get(self, prop, defval=None):
        '''
        Get a value from the info dict for the task.
        Args:
            prop (str): The name of the info value.
            defval (obj):   The default value to return if not found

        Returns:
            (obj):  The object from the info dict (or None)
        '''
        return self.info.get(prop, defval)

    def set(self, prop, valu):
        '''
        Set a value in the info dict for the task.

        Args:
            prop (str): The name of the info dict value
            valu (obj): The value to set in the info dict
        '''
        self.info[prop] = valu
{'fraction_non_alphanumeric': 0.0938573063716139, 'fraction_numerical': 0.0007630675314765357, 'mean_word_length': 1.8844884488448845, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5244924', 'n_tokens_mistral': 795, 'n_tokens_neox': 766, 'n_words': 280}