mirror of
https://github.com/python/cpython.git
synced 2025-11-01 06:01:29 +00:00
gh-140137: Handle empty collections in profiling.sampling (#140154)
This commit is contained in:
parent
a05aece543
commit
0c66da8de4
3 changed files with 97 additions and 33 deletions
|
|
@ -642,9 +642,14 @@ def sample(
|
|||
|
||||
if output_format == "pstats" and not filename:
|
||||
stats = pstats.SampledStats(collector).strip_dirs()
|
||||
print_sampled_stats(
|
||||
stats, sort, limit, show_summary, sample_interval_usec
|
||||
)
|
||||
if not stats.stats:
|
||||
print("No samples were collected.")
|
||||
if mode == PROFILING_MODE_CPU:
|
||||
print("This can happen in CPU mode when all threads are idle.")
|
||||
else:
|
||||
print_sampled_stats(
|
||||
stats, sort, limit, show_summary, sample_interval_usec
|
||||
)
|
||||
else:
|
||||
collector.export(filename)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue