Newsgroups: comp.lang.python
From: 88888 Dihedral <dihedral88...@googlemail.com>
Date: Tue, 25 Sep 2012 15:39:39 -0700 (PDT)
Local: Tues, Sep 25 2012 6:39 pm
Subject: Re: How to limit CPU usage in Python
DPalao於 2012年9月25日星期二UTC+8下午11時13分54秒寫道:
> On Jueves septiembre 20 2012 11:12:44 Rolando Cañer Roblejo escribió:
I think I'll prefer to use a generator of my object in python
> > Hi all,
> > Is it possible for me to put a limit in the amount of processor usage (%
> > CPU) that my current python script is using? Is there any module useful
> > for this task? I saw Resource module but I think it is not the module I
> > am looking for. Some people recommend to use nice and cpulimit unix
> > tools, but those are external to python and I prefer a python solution.
> > I am working with Linux (Ubuntu 10.04).
> > Best regards.
> Hola,
> Sometimes a stupid solution like the following does the trick:
> > import time
> > for t in tasks:
> > do_something(t)
> > time.sleep(some_seconds)
> where "some_seconds" is a number related to the typical time-scale of the > tasks you are doing.
> Hope it helps,
> Regards
> -- > Miller's Slogan:
> Lose a few, lose a few.
to replace the sleep from the unix world. The reason is that I am not paid from selling or buying work-stations in some business unit directly and immediately. You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||