Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error | AttributeError: 'NoneType' object has no attribute 'root_frame' #17

Closed
kbhatiya999 opened this issue May 16, 2024 · 1 comment
Closed
Assignees
Labels
bug Something isn't working

Comments

@kbhatiya999
Copy link

kbhatiya999 commented May 16, 2024

This is what get thrown if server is stopped without sending any request.

INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://0.0.0.0:8081 (Press CTRL+C to quit)
^CINFO:     Shutting down
INFO:     Waiting for application shutdown.
ERROR:    Traceback (most recent call last):
  File "/home/kas/.cache/pypoetry/virtualenvs/orchestrator-0coqT9JI-py3.11/lib/python3.11/site-packages/starlette/routing.py", line 734, in lifespan
    async with self.lifespan_context(app) as maybe_state:
  File "/home/kas/.cache/pypoetry/virtualenvs/orchestrator-0coqT9JI-py3.11/lib/python3.11/site-packages/starlette/routing.py", line 613, in __aexit__
    await self._router.shutdown()
  File "/home/kas/.cache/pypoetry/virtualenvs/orchestrator-0coqT9JI-py3.11/lib/python3.11/site-packages/starlette/routing.py", line 721, in shutdown
    await handler()
  File "/home/kas/.cache/pypoetry/virtualenvs/orchestrator-0coqT9JI-py3.11/lib/python3.11/site-packages/fastapi_profiler/profiler.py", line 174, in get_profiler_result
    f.write(renderer.render(session=self._profiler.last_session))
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kas/.cache/pypoetry/virtualenvs/orchestrator-0coqT9JI-py3.11/lib/python3.11/site-packages/pyinstrument/renderers/speedscope.py", line 210, in render
    frame = self.preprocess(session.root_frame())
                            ^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'root_frame'

ERROR:    Application shutdown failed. Exiting.
INFO:     Finished server process [1002483]


@kbhatiya999
Copy link
Author

`

Adds startup and shutdown events.

app.add_middleware(
    PyInstrumentProfilerMiddleware,
    server_app=app,  # Required to output the profile on server shutdown
    profiler_output_type="speedscope",
    is_print_each_request=False,  # Set to True to show request profile on
    # stdout on each request
    open_in_browser=False,  # Set to true to open your web-browser automatically
    # when the server shuts down
    html_file_name="speedscope.json",  # Filename for output
    async_mode="strict",
    show_all=True,
)

@sunhailin-Leo sunhailin-Leo added the bug Something isn't working label May 17, 2024
@sunhailin-Leo sunhailin-Leo self-assigned this May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants