Update of /cvsroot/freevo/kaa/base/src/notifier
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24122
Modified Files:
wrapper.py
Log Message:
add waek timer
Index: wrapper.py
===================================================================
RCS file: /cvsroot/freevo/kaa/base/src/notifier/wrapper.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** wrapper.py 12 Jul 2005 15:34:14 -0000 1.1
--- wrapper.py 13 Jul 2005 15:04:43 -0000 1.2
***************
*** 30,33 ****
--- 30,35 ----
#
-----------------------------------------------------------------------------
+ import weakref
+
try:
# try to import pyNotifier
***************
*** 86,90 ****
def expire(self):
! return self.function(*self.args, **self.kwargs)
--- 88,95 ----
def expire(self):
! if self.function(*self.args, **self.kwargs):
! return True
! self.id == None
! return False
***************
*** 97,100 ****
--- 102,129 ----
+ class WeakTimer(Timer);
+ def __init__(self, function, *args, **kwargs):
+ Timer.__init__(self, function, *args, **kwargs)
+ self.function = weakref.ref(function)
+
+ def expire(self):
+ if not self.function():
+ self.stop()
+ return False
+ if self.function()(*self.args, **self.kwargs):
+ return True
+ self.id == None
+ return False
+
+
+ class WeakOneShotTimer(WeakTimer):
+ def expire(self):
+ notifier.removeTimer(self.id)
+ self.id = None
+ if self.function():
+ self.function()(*self.args, **self.kwargs)
+ return False
+
+
class Socket(object):
def __init__(self, fd, function, *args, **kwargs):
-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog