Skip to content

Sampling profiler fails to display user-defined function in IDLE when started with the run command #142325

@smontanaro

Description

@smontanaro

Bug report

Bug description:

This is my simple test running IDLE at profiler startup (sudo as I'm running on a Mac, YMMV):

sudo -E ./python.exe -m profiling.sampling run -a --realtime-stats -d 99999 --live -m idlelib

As expected, I can also attach to a running IDLE session:

sudo -E ./python.exe -m profiling.sampling attach -a --realtime-stats -d 99999 --live <PID>

The two versions display things differently. If I attach to a running IDLE, define fib(), then call it with a large n (say, 200), it will run for a while before returning a result. I can see the recursive calls to fib in the display.

Image

If I use the run command instead, I never see fib show in the display. Instead, I see something like this:

Image

It appears all the samples in fib are credited to Misc.mainloop. I know the function is executing, given that small-n calls return quickly with the correct result, but shouldn't fib show up in the display when called with a large value for n if I use the run command to start IDLE?

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.15new features, bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytopic-profilingtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions