A long time ago, there was a post about profiling Python code 🇷🇺🐍. The conclusion was that pyflame works the best. A lot has changed since then. A few years ago, pyflame was archived. Now, it’s a part of 158 dead projects from uber.
However, py-spy has changed a lot for better. Now it is cool, stable, and saved me multiple times. I constantly use it for profiling and a few times I used it to dump the stack trace for a running process. So, forget that old post, use py-spy.