Skip to main content

Python wrapper for Austin, the frame stack sampler for CPython

Project description


Austin

Python wrapper for Austin

GitHub Actions: Tests Travis CI Codecov Documentation
PyPI Downloads
LICENSE

Synopsis • Installation • Usage • Compatibility • Documentation • Contribute

Buy Me A Coffee

Synopsis

The austin-python package is a Python wrapper around the Austin binary that provides convenience classes to quickly develop your statistical profiling tools. Whether your code is thread-based or asynchronous, austin-python has you covered. This is, for instance, how you would turn Austin into a Python application:

from austin.aio import AsyncAustin


# Make your sub-class of AsyncAustin
class EchoAsyncAustin(AsyncAustin):
    def on_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}")

    def on_sample_received(self, line):
        print(line)

    def on_terminate(self, data):
        print(data)


# Use the Proactor event loop on Windows
if sys.platform == "win32":
    asyncio.set_event_loop(asyncio.ProactorEventLoop())

try:
    # Start the Austin application with some command line arguments
    austin = EchoAsyncAustin()
    asyncio.get_event_loop().run_until_complete(
        austin.start(["-i", "10000", "python3", "myscript.py"])
    )
except (KeyboardInterrupt, asyncio.CancelledError):
    pass

The austin-python package is at the heart of the Austin TUI and the Austin Web Python 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 of collapsed stacks, to either the Speedscope JSON format or the Google pprof format. Note, however, that the Speedscope web application supports Austin native format directly.

Installation

This package can be installed from PyPI with

pip install --user austin-python --upgrade

Please note that austin-python requires the Austin binary. The default lookup locations are, in order,

  • current working directory;
  • the AUSTINPATH environment variable which gives the path to the folder that contains the Austin binary;
  • the .austinrc TOML configuration file in the user's home folder, e.g. ~/.austinrc on Linux (see below for a sample .austinrc file);
  • the PATH environment variable.

A sample .austinrc file would look like so

binary = "/path/to/austin"

Usage

A 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 the Austin TUI and the Austin Web Python applications to see how they leverage austin-python.

Format conversion

As it was mentioned before, this package also comes with two scripts for format conversion, namely austin2speedscope and austin2pprof. They both take two mandatory arguments, that is, the input and output file. For example, to convert the Austin profile data file myscript.aprof to the Google pprof data file myscript.pprof, you can run

austin2pprof myscript.aprof myscript.pprof

The package also provide the austin-compress utility to compress the Austin raw samples by aggregation.

Compatibility

The austin-python package is tested on Linux, macOS and Windows with Python 3.6-3.9.

Documentation

The official documentation is hosted on readthedocs.io at austin-python.readthedocs.io.

Contribute

If you want to help with the development, then have a look at the open issues and have a look at the contributing guidelines before you open a pull request.

You can also contribute to the development by either becoming a Patron on Patreon, by buying me a coffee on BMC or by chipping in a few pennies on PayPal.Me.

Buy Me A Coffee

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

austin-python-1.0.0a2.tar.gz (42.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

austin_python-1.0.0a2-py3-none-any.whl (62.5 kB view details)

Uploaded Python 3

File details

Details for the file austin-python-1.0.0a2.tar.gz.

File metadata

  • Download URL: austin-python-1.0.0a2.tar.gz
  • Upload date:
  • Size: 42.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.7 CPython/3.9.5 Linux/5.8.0-1033-azure

File hashes

Hashes for austin-python-1.0.0a2.tar.gz
Algorithm Hash digest
SHA256 ef3aba8f21e5b2d5aadcbed37c07989614eda5a26146c8b51db574ff3b511b08
MD5 e66852916a7368d6ce613d1b710899dd
BLAKE2b-256 ccd5c1c0d8b7cd53658f0305bd038a6893f98e0966b1b8f88488d3e3916cde70

See more details on using hashes here.

File details

Details for the file austin_python-1.0.0a2-py3-none-any.whl.

File metadata

  • Download URL: austin_python-1.0.0a2-py3-none-any.whl
  • Upload date:
  • Size: 62.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.7 CPython/3.9.5 Linux/5.8.0-1033-azure

File hashes

Hashes for austin_python-1.0.0a2-py3-none-any.whl
Algorithm Hash digest
SHA256 2bf339d6fc851008dfa1b63be42e2d4e8f492f059044c9a9e2ae6f2f65c4d18b
MD5 099f4a2d50544ec5614466f149630167
BLAKE2b-256 9833fcd8894a15a38fb63d2112c7845b65c78e14f3cce2e0cce4116a947a86fe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page