Search code examples
pythonpythonanywhere

Is there a way to access PythonAnywhere CPU Allowance from a script?


I'm curious how my CPU allowance on PythonAnywhere is trending over several days. Is there a way to access this value from a script such that I can setup a Schedule task to take readings once an hour and save them?


Solution

  • PythonAnywhere dev here: There isn't, unfortunately, but that's a great suggestion! I'll add it to our list.

    Update

    And here is new (2019-09-11) API endpoint:

    /api/v0/user/{username}/cpu/
    

    GET Returns information about cpu usage in json format:

    {
        "daily_cpu_limit_seconds": <int>,
        "next_reset_time": <isoformat>,
        "daily_cpu_total_usage_seconds": <float>
    }
    

    see the blog post with example of usage.