P403n1x87 / austin

Python frame stack sampler for CPython
https://pypi.org/project/austin-dist/
GNU General Public License v3.0
1.7k stars 51 forks source link

Feature Request: Call Austin programmatically #224

Closed davidandreoletti closed 2 days ago

davidandreoletti commented 2 months ago

Description

Problem:

A python program runs and gets stuck somewhere (except main thread). I would like to send a signal (eg USR2) to the python process which then calls Austin programmatically to produce a sample to see all stack frame at the time of the signal is received.

Workaround Right now, Austin is cli program. It requires:

A python programming interface handling these would facilitate embedding Austin in applications directly:

signal.signal(signal.SIGUSR2, lambda sig, frame: austin.sample(max_sample=1,where=os.getpid(),children=True,...., to=/tmp/sample.out))

Additional Information

Your project is fantastic, well written, clean and useful. Thank you.

P403n1x87 commented 2 months ago

@davidandreoletti thanks for your request. This is perhaps something that can be baked into austin-python. It would still be the process you described, but it would be done automatically when a signal is sent to the process. In the meantime, echion already implements this, so perhaps you can give that a try 🙂 .