Package: austin-python
Python wrapper for AustinSynopsis•Installation•Usage•Compatibility•Documentation•ContributeSynopsisTheaustin-pythonpackage is a Python wrapper around theAustinbinary that
provides convenience classes to quickly develop your statistical profiling
tools. Whether your code is thread-based or asynchronous,austin-pythonhas
you covered. This is, for instance, how you would turn Austin into a Python
application:fromaustin.aioimportAsyncAustin# Make your sub-class of AsyncAustinclassEchoAsyncAustin(AsyncAustin):defon_ready(self,process,child_process,command_line):print(f"Austin PID:{process.pid}")print(f"Python PID:{child_process.pid}")print(f"Command Line:{command_line}")defon_sample_received(self,line):print(line)defon_terminate(self,data):print(data)# Use the Proactor event loop on Windowsifsys.platform=="win32":asyncio.set_event_loop(asyncio.ProactorEventLoop())try:# Start the Austin application with some command line argumentsaustin=EchoAsyncAustin()asyncio.get_event_loop().run_until_complete(austin.start(["-i","10000","python3","myscript.py"]))except(KeyboardInterrupt,asyncio.CancelledError):passTheaustin-pythonpackage is at the heart of theAustin
TUIand theAustin
WebPython applications. Go check them
out if you are looking for full-fledged usage examples.Included with the package come two applications for the conversion of Austin
collected output, which is in the form ofcollapsed
stacks, to either theSpeedscopeJSON format or theGoogle pprof
format. Note, however, that the Speedscope web
application supports Austin native format directly.InstallationThis package can be installed from PyPI withpipinstall--useraustin-python--upgradePlease note thataustin-pythonrequires theAustinbinary. The default
lookup locations are, in order,current working directory;theAUSTINPATHenvironment variable which gives the path to the folder that
contains the Austin binary;the.austinrcTOML configuration file in the user's home folder, e.g.~/.austinrcon Linux (see below for a sample.austinrcfile);thePATHenvironment variable.A sample.austinrcfile would look like sobinary="/path/to/austin"UsageA simple example of an echo application was shown above. Other examples using,
e.g., threads, can be found in the official documentation. You can also browse
through the code of theAustin TUIand theAustin WebPython
applications to see how they leverageaustin-python.Format conversionAs it was mentioned before, this package also comes with two scripts for format
conversion, namelyaustin2speedscopeandaustin2pprof. They both take two
mandatory arguments, that is, the input and output file. For example, to convert
the Austin profile data filemyscript.aprofto the Google pprof data filemyscript.pprof, you can runaustin2pprofmyscript.aprofmyscript.pprofThe package also provide theaustin-compressutility to compress the Austin
raw samples by aggregation.CompatibilityThe latestaustin-pythonpackage is tested on Linux, macOS and Windows with
Python 3.8-3.12.DocumentationThe official documentation is hosted on readthedocs.io ataustin-python.readthedocs.io.ContributeIf you want to help with the development, then have a look at the open issues
and have a look at thecontributing guidelinesbefore you
open a pull request.You can also contribute to the development by eitherbecoming a
Patronon Patreon, bybuying me a
coffeeon BMC or by chipping in a few
pennies onPayPal.Me.