Forums

Get CPU seconds left from Python script

We would like to see the CPU seconds left (or the CPU usage) from a Python script as also suggested here: https://stackoverflow.com/questions/22978134/is-there-a-way-to-access-pythonanywhere-cpu-allowance-from-a-script

Is there any update on this suggestion? If not, +1 for this one :)

Best regards, Karsten

It's on our list, but hasn't reached the top yet -- I've added an upvote on your behalf.

Hi, Just expressing my wish for this to be implemented. I currently use a selenium scraper to get used, remaining, time-till-reset, but this itself uses a few CPU seconds logging in and wotnot and is not really something I want to keep doing. How about adding it to the beta API, or is it already, or any better solutions? Thanks. :)

No problem. I have upvoted the ticket for you.

Here it is:

/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 new blog post.