Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #30098 > unrolled thread

Re: How to limit CPU usage in Python

Started byDPalao <dpalao.python@gmail.com>
First post2012-09-25 17:07 +0200
Last post2012-09-25 15:39 -0700
Articles 3 — 2 participants

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: How to limit CPU usage in Python DPalao <dpalao.python@gmail.com> - 2012-09-25 17:07 +0200
    Re: How to limit CPU usage in Python 88888 Dihedral <dihedral88888@googlemail.com> - 2012-09-25 15:39 -0700
    Re: How to limit CPU usage in Python 88888 Dihedral <dihedral88888@googlemail.com> - 2012-09-25 15:39 -0700

#30098 — Re: How to limit CPU usage in Python

FromDPalao <dpalao.python@gmail.com>
Date2012-09-25 17:07 +0200
SubjectRe: How to limit CPU usage in Python
Message-ID<mailman.1345.1348586032.27098.python-list@python.org>
On Jueves septiembre 20 2012 11:12:44 Rolando Cañer Roblejo escribió:
> 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.

[toc] | [next] | [standalone]


#30131

From88888 Dihedral <dihedral88888@googlemail.com>
Date2012-09-25 15:39 -0700
Message-ID<5c05ff8d-9bca-4c21-a7b6-93e010c3cb20@googlegroups.com>
In reply to#30098
DPalao於 2012年9月25日星期二UTC+8下午11時13分54秒寫道:
> On Jueves septiembre 20 2012 11:12:44 Rolando Cañer Roblejo escribió:
> 
> > 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.

I think I'll prefer to use a generator of my object in python
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.

[toc] | [prev] | [next] | [standalone]


#30132

From88888 Dihedral <dihedral88888@googlemail.com>
Date2012-09-25 15:39 -0700
Message-ID<mailman.1382.1348612782.27098.python-list@python.org>
In reply to#30098
DPalao於 2012年9月25日星期二UTC+8下午11時13分54秒寫道:
> On Jueves septiembre 20 2012 11:12:44 Rolando Cañer Roblejo escribió:
> 
> > 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.

I think I'll prefer to use a generator of my object in python
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.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web