python-for-android
python-for-android copied to clipboard
CPU too high using FullScreenWrapper2
What steps will reproduce the problem?
1. Start a script that uses the FullScreenWrapper2.py
What is the expected output? What do you see instead?
What version of the product are you using? On what operating system?
I think it's no dependent. But it's a Samsung Galaxy 3 with android 4.04
Please provide any additional information below.
The problem is that CPU raises 25% on my device. It's a lot of CPU
I see on LogCat that there are a lot or callings to EventPoll per second
I put a sleep command just after the eventPol calling and CPU is less than 1%,
without perceiving any problem, but I don't know that this is the best solution:
...
while(True):
evt=cls.get_android_instance().eventPoll()
time.sleep(0.25)
...
if(len(evt.result)>0):
Original issue reported on code.google.com by [email protected]
on 20 Aug 2012 at 6:31
Python is known to eat all CPU available in a while loop with no sleep, 4
cores, 25% ;).
Original comment by [email protected]
on 20 Aug 2012 at 7:03
hmm... interesting... i've googled a bit & this seems to be a common question
in Python and the "solutions" that i seem to come across seem to involve using
a small sleep like what's suggested here.
I guess running mobile device CPUs at 25%+ for extended periods would overheat
them. Has anyone come across any better approaches on this?
If there's no better way around this, I can probably add a method to set a
customisable delay in FullScreenWrapper2 eventloop like above.
Original comment by [email protected]
on 25 Aug 2012 at 11:19
- Changed state: Accepted
http://stackoverflow.com/questions/9349588/python-process-takes-100-cpu