¡@

Home 

OpenStack Study: threading.py

OpenStack Index

**** CubicPower OpenStack Study ****

# Copyright 2013 Red Hat, Inc.

#

# 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.

"""Provides thread and stack-trace views

This module provides a collection of views for

visualizing threads, green threads, and stack traces

in human-readable form.

"""

import nova.openstack.common.report.views.jinja_view as jv

**** CubicPower OpenStack Study ****

class StackTraceView(jv.JinjaView):

"""A Stack Trace View

This view displays stack trace models

**** CubicPower OpenStack Study ****

class GreenThreadView(object):

"""A Green Thread View

This view displays a green thread provided by the data

model :class:`openstack.common.report.models.threading.GreenThreadModel` # noqa

"""

FORMAT_STR = "------{thread_str: ^60}------" + "\n" + "{stack_trace}"

**** CubicPower OpenStack Study ****

    def __call__(self, model):

        return self.FORMAT_STR.format(

            thread_str=" Green Thread ",

            stack_trace=model.stack_trace

        )

**** CubicPower OpenStack Study ****

class ThreadView(object):

"""A Thread Collection View

This view displays a python thread provided by the data

model :class:`openstack.common.report.models.threading.ThreadModel` # noqa

"""

FORMAT_STR = "------{thread_str: ^60}------" + "\n" + "{stack_trace}"

**** CubicPower OpenStack Study ****

    def __call__(self, model):

        return self.FORMAT_STR.format(

            thread_str=" Thread #{0} ".format(model.thread_id),

            stack_trace=model.stack_trace

        )