Big-B702 / python-for-android

Automatically exported from code.google.com/p/python-for-android
Apache License 2.0
0 stars 0 forks source link

CPU too high using FullScreenWrapper2 #57

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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 nangdo...@gmail.com on 20 Aug 2012 at 6:31

GoogleCodeExporter commented 9 years ago
Python is known to eat all CPU available in a while loop with no sleep, 4 
cores, 25% ;).

Original comment by anthony....@gmail.com on 20 Aug 2012 at 7:03

GoogleCodeExporter commented 9 years ago
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 srinathd...@gmail.com on 25 Aug 2012 at 11:19