benfred / py-spy

Sampling profiler for Python programs
MIT License
12.2k stars 401 forks source link

How to record with python_program #475

Closed caimaoy closed 2 years ago

caimaoy commented 2 years ago

It can record with

py-spy record [OPTIONS] --output <filename> --pid <pid> [python_program] <arg1> <arg2> ...

but if arg1 and arg2 have the args like -g or --pid and in another situation python_program use vitrulenv or pyenv how to solve the problems?I can only record with --pid without [python_program] <arg1> <arg2>

Jongy commented 2 years ago

The convention for shell programs is to use -- to separate between arguments of different commands on the same commandline, I suppose you could try that. If that's not supported by py-spy - then it should be.

py-spy record [OPTIONS] --output <filename> --pid <pid> -- [python_program] <arg1> <arg2> ...
benfred commented 2 years ago

@Jongy is exactly right - you just separate the python program commandline with a --