Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

debugtoolbar crash on attribute error #12

Closed
19emtuck opened this Issue · 4 comments

2 participants

@19emtuck

pyramid debugtoolbar last tip (3ff51ce) crash

AttributeError: 'PerformanceDebugPanel' object has no attribute '_end_rusage'

URL: http://127.0.0.1:6543/
File 'C:\DEV\py27venv\lib\site-packages\weberror-0.10.3-py2.7.egg\weberror\evalexception.py', line 431 in respond
app_iter = self.application(environ, detect_start_response)
File 'C:\DEV\py27venv\lib\site-packages\repoze.tm2-1.0b1-py2.7.egg\repoze\tm\init.py', line 23 in call
result = self.application(environ, save_status_and_headers)
File 'C:\DEV\py27venv\lib\site-packages\pyramid-1.1.1dev-py2.7.egg\pyramid\router.py', line 176 in call
response = self.handle_request(request)
File 'C:\DEV\py27venv\lib\site-packages\pyramid_debugtoolbar-0.2-py2.7.egg\pyramid_debugtoolbar\toolbar.py', line 137 in toolbar_tween
toolbar.process_response(response)
File 'C:\DEV\py27venv\lib\site-packages\pyramid_debugtoolbar-0.2-py2.7.egg\pyramid_debugtoolbar\toolbar.py', line 43 in process_response
vars, request=request)
File 'C:\DEV\py27venv\lib\site-packages\pyramid-1.1.1dev-py2.7.egg\pyramid\renderers.py', line 69 in render
return helper.render(value, None, request=request)
File 'C:\DEV\py27venv\lib\site-packages\pyramid-1.1.1dev-py2.7.egg\pyramid\renderers.py', line 416 in render
result = renderer(value, system_values)
File 'C:\DEV\py27venv\lib\site-packages\pyramid_jinja2-1.1-py2.7.egg\pyramid_jinja2\init.py', line 277 in call
return self.template.render(system)
File 'C:\DEV\py27venv\lib\site-packages\jinja2-2.6-py2.7.egg\jinja2\environment.py', line 894 in render
return self.environment.handle_exception(exc_info, True)
File 'C:\DEV\py27venv\lib\site-packages\pyramid_debugtoolbar-0.2-py2.7.egg\pyramid_debugtoolbar\templates\toolbar.jinja2', line 62 in top-level template code
{{ panel.content()|safe }}
File 'C:\DEV\py27venv\lib\site-packages\pyramid_debugtoolbar-0.2-py2.7.egg\pyramid_debugtoolbar\panels\performance.py', line 157 in content
utime = 1000 * self._elapsed_ru('ru_utime')
File 'C:\DEV\py27venv\lib\site-packages\pyramid_debugtoolbar-0.2-py2.7.egg\pyramid_debugtoolbar\panels\performance.py', line 153 in _elapsed_ru
return getattr(self._end_rusage, name) - getattr(self._start_rusage,
AttributeError: 'PerformanceDebugPanel' object has no attribute '_end_rusage'

@19emtuck

this issue has been detected on win32 system
because of non availability of 'resource' module, debugtoolbar crash

normaly if resource module is not available we should'nt see content panel.
Unfortunatly no test is done in PerformanceDebugPanel.content method .

I've patch, and test if it has 'resource' or not and provide value to 0.0 to allow panel
to be publish (cause i'm interesting to publish total time value)

this is the head of PerformanceDebugPanel.content method inside performance module

def content(self):
    if self.has_resource:
        utime = 1000 * self._elapsed_ru('ru_utime')
        stime = 1000 * self._elapsed_ru('ru_stime')
        vcsw = self._elapsed_ru('ru_nvcsw')
        ivcsw = self._elapsed_ru('ru_nivcsw')
        minflt = self._elapsed_ru('ru_minflt')
        majflt = self._elapsed_ru('ru_majflt')
    else :
        # on win32 resource don't exist
        utime = 0.0
        stime = 0.0
        vcsw = 0.0
        ivcsw = 0.0
        minflt = 0.0
        majflt = 0.0

I think it could be more interesting to push None value instead of 0.0 and publish an 'not available' comments
instead.

@mmerickel mmerickel referenced this issue from a commit
@mmerickel mmerickel PerformancePanel wasn't working on windows. Fixes issue #12.
The `resource` module is not available on windows.
1732006
@mmerickel
Owner

Anyone with a windows box feel like testing this fix?

@19emtuck

I test it, and it's not enough vars is used but not referenced

just add

    else :
        vars = {}

or referenced vars before

see traceback below

URL: http://127.0.0.1:6543/updatecanevas
File 'C:\DEV\py27venv\lib\site-packages\weberror-0.10.3-py2.7.egg\weberror\evalexception.py', line 431 in respond
app_iter = self.application(environ, detect_start_response)
File 'C:\DEV\py27venv\lib\site-packages\repoze.tm2-1.0b1-py2.7.egg\repoze\tm\init.py', line 23 in call
result = self.application(environ, save_status_and_headers)
File 'C:\DEV\py27venv\lib\site-packages\pyramid-1.2dev-py2.7.egg\pyramid\router.py', line 176 in call
response = self.handle_request(request)
File 'C:\DEV\py27venv\lib\site-packages\pyramid_debugtoolbar-0.2-py2.7.egg\pyramid_debugtoolbar\toolbar.py', line 141 in toolbar_tween
toolbar.process_response(response)
File 'C:\DEV\py27venv\lib\site-packages\pyramid_debugtoolbar-0.2-py2.7.egg\pyramid_debugtoolbar\toolbar.py', line 48 in process_response
vars, request=request)
File 'C:\DEV\py27venv\lib\site-packages\pyramid-1.2dev-py2.7.egg\pyramid\renderers.py', line 69 in render
return helper.render(value, None, request=request)
File 'C:\DEV\py27venv\lib\site-packages\pyramid-1.2dev-py2.7.egg\pyramid\renderers.py', line 418 in render
result = renderer(value, system_values)
File 'C:\DEV\py27venv\lib\site-packages\pyramid_jinja2-1.1-py2.7.egg\pyramid_jinja2\init.py', line 277 in call
return self.template.render(system)
File 'C:\DEV\py27venv\lib\site-packages\jinja2-2.6-py2.7.egg\jinja2\environment.py', line 894 in render
return self.environment.handle_exception(exc_info, True)
File 'C:\DEV\py27venv\lib\site-packages\pyramid_debugtoolbar-0.2-py2.7.egg\pyramid_debugtoolbar\templates\toolbar.jinja2', line 62 in top-level template code
{{ panel.content()|safe }}
File 'C:\DEV\py27venv\lib\site-packages\pyramid_debugtoolbar-0.2-py2.7.egg\pyramid_debugtoolbar\panels\performance.py', line 196 in content
vars.update({
UnboundLocalError: local variable 'vars' referenced before assignment

@19emtuck

it's perfect :)
thx !

@19emtuck 19emtuck closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.