Reply
Thread Tools
Posts: 133 | Thanked: 172 times | Joined on Jul 2009 @ Travel bag
#1
gtk seems to be providing two timeout functions: gtk_timeout_add and gtk_timeout_add_seconds. The later is being suggested in various forums as in here and here, since it groups the program 'wake-ups' to reduce the frequency as against _timeout_add. The benefit is that, using _timeout_add_seconds reduces the number of program wake-ups and saves battery power..

If this is true, I wanted to use :
Code:
gobject.timeout_add_seconds(1, self.update)
as against
Code:
gobject.timeout_add(1000, self.update)
However when I use "gobject.timeout_add_seconds", in a desktop widget context for diablo, I get this error msg
AttributeError: 'module' object has no attribute 'timeout_add_seconds'
Any pointers on how I can use timeout_add_seconds to save power on the device.

TiA
Shin
 
Posts: 53 | Thanked: 90 times | Joined on Nov 2009 @ Manaus, Brazil
#2
Originally Posted by shin View Post
[...] I wanted to use :
Code:
gobject.timeout_add_seconds(1, self.update)
as against
Code:
gobject.timeout_add(1000, self.update)
However when I use "gobject.timeout_add_seconds", in a desktop widget context for diablo, I get this error msg
[...]
gobject.timeout_add_seconds is not available on Diablo, because the underlying glib version (2.12.12-1osso13 according to http://maemo.org/packages/view/libglib2.0-0) does not have this function. See:

http://maemo.org/api_refs/4.1/glib2....vent-Loop.html

This function has been added in 2.14 according to:

http://library.gnome.org/devel/glib/...ut-add-seconds

That's why you will only find it on Maemo 5 (fremantle). This applies both to C and Python.
__________________
Anderson Lizardo
 

The Following 2 Users Say Thank You to lizardo For This Useful Post:
epage's Avatar
Posts: 1,684 | Thanked: 1,562 times | Joined on Jun 2008 @ Austin, TX
#3
Too add to the statement on _seconds being new, I'll include what I do for this

Code:
 def _old_timeout_add_seconds(timeout, callback):
         return gobject.timeout_add(timeout * 1000, callback)


 def _timeout_add_seconds(timeout, callback):
         return gobject.timeout_add_seconds(timeout, callback)


 try:
         gobject.timeout_add_seconds
         timeout_add_seconds = _timeout_add_seconds
 except AttributeError:
         timeout_add_seconds = _old_timeout_add_seconds
__________________
770, n810, n900, Ideapad S10-3t
TheOneRing, DialCentral, Gonvert, Quicknote, Multilist, ejpi, nQa, Waters of Shiloah
Programming Blog
 

The Following User Says Thank You to epage For This Useful Post:
Posts: 133 | Thanked: 172 times | Joined on Jul 2009 @ Travel bag
#4
Thank you epage and lizardo

@epage - So if I understand your suggestion correctly, the code snippet you provided basically helps the code work on both diablo and Maemo5 and that it is essentially an exception handler for diablo..

Is there any other way to reduce the program wake-ups and IO ( specifically in the diablo context) to replace

gobject.timeout_add(1000, self.update)
 
Reply


 
Forum Jump


All times are GMT. The time now is 08:21.