Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User kawan95's Avatar
    Join Date
    Jul 2007
    Posts
    18
    My Python program shall run in background and it hast to do something every 5 minutes. Does anyone know the best method to save battery? I tried using e32.Ao_timer(), this rapidly empties my N95 battery.

  2. #2
    Super Contributor Rafael T.'s Avatar
    Join Date
    Feb 2008
    Location
    Belo Horizonte, Brazil
    Posts
    744
    can you tell me what was the code you used with appswitch for running in background?!

  3. #3
    Regular Contributor Dansco's Avatar
    Join Date
    Mar 2003
    Posts
    115
    Quote Originally Posted by kawan95 View Post
    My Python program shall run in background and it hast to do something every 5 minutes. Does anyone know the best method to save battery? I tried using e32.Ao_timer(), this rapidly empties my N95 battery.
    I think if the app is constantly running and checking something every 5 mins, the battery will drain. That's 12 times an hour mate. Maybe it could check for say 15 mins?

  4. #4
    Registered User kawan95's Avatar
    Join Date
    Jul 2007
    Posts
    18
    Quote Originally Posted by Dansco View Post
    I think if the app is constantly running and checking something every 5 mins, the battery will drain. That's 12 times an hour mate. Maybe it could check for say 15 mins?
    Certainly it could. And perhaps e32.Ao_Timer() isn't the best way to wait in background... I'll try.

  5. #5
    Registered User kawan95's Avatar
    Join Date
    Jul 2007
    Posts
    18
    Quote Originally Posted by Rafael T. View Post
    can you tell me what was the code you used with appswitch for running in background?!
    My first step was not to use appswitch but start the program an put it into background manually.

    The code ist like this:

    class Scheduler(object):
    iIntervalMin=20
    def __init__(self):
    self._timer = e32.Ao_timer()
    def set_timer(self,ixIntervallMin):
    self._timer.cancel()
    self.iIntervallMin = ixIntervallMin
    self.start_timer()
    def start_timer(self):
    self._timer.after(self.iIntervallMin*60, self.handler)
    def __del__(self):
    self._timer.cancel()
    def handler(self):
    self.start_timer()
    DoSomethingEvery20Minutes()


    app_lock = e32.Ao_lock()
    app.exit_key_handler=EndProgram
    scheduler = Scheduler()
    while running:
    e32.ao_yield()

  6. #6
    Super Contributor Rafael T.'s Avatar
    Join Date
    Feb 2008
    Location
    Belo Horizonte, Brazil
    Posts
    744
    thanks!!! but my application rotates the screen automactily with the N95 rotation sensor, this code should make it rotate in menus and apps too?

  7. #7
    Nokia Developer Moderator croozeus's Avatar
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,650
    Quote Originally Posted by kawan95 View Post
    My first step was not to use appswitch but start the program an put it into background manually.

    The code ist like this:

    class Scheduler(object):
    iIntervalMin=20
    def __init__(self):
    self._timer = e32.Ao_timer()
    def set_timer(self,ixIntervallMin):
    self._timer.cancel()
    self.iIntervallMin = ixIntervallMin
    self.start_timer()
    def start_timer(self):
    self._timer.after(self.iIntervallMin*60, self.handler)
    def __del__(self):
    self._timer.cancel()
    def handler(self):
    self.start_timer()
    DoSomethingEvery20Minutes()


    app_lock = e32.Ao_lock()
    app.exit_key_handler=EndProgram
    scheduler = Scheduler()
    while running:
    e32.ao_yield()
    Hi kawan95,

    Please use the CODE tabs to post any code snippets as indentations are maintained thus and it makes better for understanding.

    Best Regards
    Croozeus
    Pankaj Nathani
    www.croozeus.com

  8. #8
    I was worried about the power consumption of e32.Ao_timer() too. So I tried to estimate the power consumption with Nokia's Energy Profiler http://www.forum.nokia.com/main/reso...ergy_profiler/. Although I used an interval of just 5 seconds I couldn't detect any significant differences in power consumption over a period of 15 min compared to 'idle'. A test program which ran in background with 1 min update interval didn't cause any noticeable battery drain when running for about 10 days. Done with 1.4.1 on a 6120 classic.

    Martin

Similar Threads

  1. Please help installing Python libraries on S60
    By ericroijen in forum Python
    Replies: 11
    Last Post: 2009-07-18, 10:43
  2. Graphics in background Python processes?
    By canopus961 in forum Python
    Replies: 8
    Last Post: 2008-07-21, 21:31
  3. Replies: 0
    Last Post: 2007-12-22, 07:13
  4. How to read battery level in Python?
    By asimo_san in forum Python
    Replies: 2
    Last Post: 2007-02-21, 10:19
  5. Python and Background
    By rexwal in forum Python
    Replies: 4
    Last Post: 2006-12-18, 11:44

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved