benfred / py-spy

Sampling profiler for Python programs
MIT License
12.14k stars 400 forks source link

Can py-spy dump use `python a.py` instead of pid like py-spy top -- python a.py? #573

Open yihong0618 opened 1 year ago

yihong0618 commented 1 year ago

cat a.py


def foo():
    return 2

def bar():
    return 3

if __name__ == "__main__":
    import time
    print(foo() + bar())
    time.sleep(30)

py-spy top python a.py work

py-spy dump python a.py (do not support)

Thanks for your great repo~

Jongy commented 1 year ago

Hi @yihong0618 , what would py-spy dump python a.py do? py-spy dump produces a momentary snapshot, so what sense would it make to "dump" a process that hasn't started yet :sweat_smile: ?

yihong0618 commented 1 year ago

Thanks, what I want is dump all the functions the scripts go through maybe with locals.