fastapi_profiler: Runtime Error: This profiler is not currently running
This is my first time using a profiler, how do i make the profiler run? This is how i add the middleware
if app_config.PROFILE_MODE:
print("__________________profile mode__________________")
from fastapi_profiler import PyInstrumentProfilerMiddleware
app.add_middleware(
PyInstrumentProfilerMiddleware,
server_app=app, # Required to output the profile on server shutdown
profiler_output_type="html",
is_print_each_request=False, # Set to True to show request profile on
# stdout on each request
open_in_browser=True, # Set to true to open your web-browser automatically
# when the server shuts down
html_file_name="example_profile.html", # Filename for output)
)
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 22 (9 by maintainers)
@nhhviet98
pyinstrumentis thread-unsafe in getting stack information in concurrent scenarios, so sequential calls don’t cause problems, concurrent calls do.set
async_mode="strict"https://pyinstrument.readthedocs.io/en/latest/reference.html#pyinstrument.Profiler.async_mode