profile_request: Support only synchronous responses for now.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2023-07-19 14:31:19 -07:00 committed by Tim Abbott
parent ff6cf54716
commit 32a8151ce8
1 changed files with 1 additions and 0 deletions

View File

@ -27,6 +27,7 @@ def profile_request(request: HttpRequest) -> HttpResponseBase:
prof = cProfile.Profile()
with tempfile.NamedTemporaryFile(prefix="profile.data.", delete=False) as stats_file:
response = LogRequests(get_response)(request)
assert isinstance(response, HttpResponseBase) # async responses not supported here for now
prof.dump_stats(stats_file.name)
logging.info("Profiling data written to %s", stats_file.name)
return response