[Tutor] better resolution on time.sleep()?

Alan G alan.gauld at freenet.co.uk
Tue May 24 09:00:47 CEST 2005


> I'm running an application that has a polling loop to check a serial
port
> for certain signals, and on my laptop I can get about 6700 samples
per
> second, which (of course) consumes 100% CPU; which may impact
battery life.

Consuming 100% CPU won't make much difference, the CPU is running all
the time anyway (when its not asleep). What will consume batteries
much
faster is if you are accessing hardware such as disk or modem or other
power hungry devices.

> Anyone know of:
>
> 1) a working millisleep/microsleep implementation for python 2.2+?

I've never tried in Python but can you use select()?
I've used it in C for short duration intervals.

Just a thought.

Alan G




More information about the Tutor mailing list