<commit_before>#!/usr/bin/python

# Copyright 2015 Huawei Devices USA Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# Authors:
#       <NAME> <<EMAIL>>

"""
    TaskState: Possible task states from linux/sched.h
    Task: Runnable thread (process) executed on CPU.
"""
from six import integer_types
from collections import namedtuple, defaultdict
from .common import ConstantBase

TaskBase = namedtuple("Task",
    [
    'name', # Task name
    'pid', # Process pid
    'prio', # Task priority
    'tgid', # Thread group ID
    'ppid', # Parent process ID
    ]
)

class TaskState(ConstantBase):
    RUNNING = ()
    SLEEPING = ()
    UNINTERRUPTIBLE = ()
    STOPPED = ()

    EXIT_DEAD = ()
    EXIT_ZOMBIE = ()

    TASK_DEAD = ()
    TASK_WAKEKILL = ()
    TASK_WAKING = ()
    TASK_PARKED = ()

    TRACED = ()
    UNKNOWN = ()

    # based on sched_wakeup
    RUNNABLE = ()


# linux/sched.h
# /trace/events/sched.h
TaskStateMapping = defaultdict(lambda: TaskState.UNKNOWN)
state_dict = {
    'S' : TaskState.SLEEPING,
    'D' : TaskState.UNINTERRUPTIBLE,
    'T' : TaskState.STOPPED,
    't' : TaskState.TRACED,
    'Z' : TaskState.EXIT_DEAD,
    'X' : TaskState.EXIT_ZOMBIE,
    'x' : TaskState.TASK_DEAD,
    'K' : TaskState.TASK_WAKEKILL,
    'W' : TaskState.TASK_WAKING,
    'P' : TaskState.TASK_PARKED,
    'R+': TaskState.RUNNABLE,
    'R' : TaskState.RUNNING,
}

TaskStateMapping.update(state_dict)

class Task(TaskBase):

    __slots__ = ()

    def __new__(cls, name, pid, prio=None, tgid=None, ppid=None, **kwargs):<commit_msg>Task: Oops in taskstate<commit_after>#!/usr/bin/python

# Copyright 2015 Huawei Devices USA Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# Authors:
#       <NAME> <<EMAIL>>

"""
    TaskState: Possible task states from linux/sched.h
    Task: Runnable thread (process) executed on CPU.
"""
from six import integer_types
from collections import namedtuple, defaultdict
from .common import ConstantBase

TaskBase = namedtuple("Task",
    [
    'name', # Task name
    'pid', # Process pid
    'prio', # Task priority
    'tgid', # Thread group ID
    'ppid', # Parent process ID
    ]
)

class TaskState(ConstantBase):
    RUNNING = ()
    SLEEPING = ()
    UNINTERRUPTIBLE = ()
    STOPPED = ()

    EXIT_DEAD = ()
    EXIT_ZOMBIE = ()

    TASK_DEAD = ()
    TASK_WAKEKILL = ()
    TASK_WAKING = ()
    TASK_PARKED = ()

    TRACED = ()
    UNKNOWN = ()

    # based on sched_wakeup
    RUNNABLE = ()


# linux/sched.h
# /trace/events/sched.h
TaskStateMapping = defaultdict(lambda: TaskState.UNKNOWN)
state_dict = {
    'S' : TaskState.SLEEPING,
    'D' : TaskState.UNINTERRUPTIBLE,
    'T' : TaskState.STOPPED,
    't' : TaskState.TRACED,
    'Z' : TaskState.EXIT_ZOMBIE,
    'X' : TaskState.EXIT_DEAD,
    'x' : TaskState.TASK_DEAD,
    'K' : TaskState.TASK_WAKEKILL,
    'W' : TaskState.TASK_WAKING,
    'P' : TaskState.TASK_PARKED,
    'R+': TaskState.RUNNABLE,
    'R' : TaskState.RUNNING,
}

TaskStateMapping.update(state_dict)

class Task(TaskBase):

    __slots__ = ()

    def __new__(cls, name, pid, prio=None, tgid=None, ppid=None, **kwargs):
{'fraction_non_alphanumeric': 0.11766121270452358, 'fraction_numerical': 0.0038498556304138597, 'mean_word_length': 3.303312629399586, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6836064', 'n_tokens_mistral': 1461, 'n_tokens_neox': 1404, 'n_words': 394}