WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] XendDomain.py, scheduler.py:

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] XendDomain.py, scheduler.py:
From: BitKeeper Bot <riel@xxxxxxxxxxx>
Date: Wed, 18 May 2005 18:08:47 +0000
Delivery-date: Wed, 18 May 2005 19:01:44 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: Xen Development List <xen-devel@xxxxxxxxxxxxxxxxxxx>
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
ChangeSet 1.1456, 2005/05/18 19:08:47+01:00, cl349@xxxxxxxxxxxxxxxxxxxx

        XendDomain.py, scheduler.py:
          Simplify scheduler.
        Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>



 XendDomain.py |    9 +++------
 scheduler.py  |   43 +++++++++++++++++++------------------------
 2 files changed, 22 insertions(+), 30 deletions(-)


diff -Nru a/tools/python/xen/xend/XendDomain.py 
b/tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py       2005-05-18 15:02:23 -04:00
+++ b/tools/python/xen/xend/XendDomain.py       2005-05-18 15:02:23 -04:00
@@ -19,7 +19,7 @@
 from XendError import XendError
 from XendLogging import log
 
-from scheduler import Scheduler
+import scheduler
 
 from xen.xend.server import channel
 
@@ -83,9 +83,6 @@
     """Table of pending domain shutdowns, indexed by domain id."""
     shutdowns_by_id = {}
 
-    """Table of delayed calls."""
-    scheduler = Scheduler()
-    
     def __init__(self):
         # Hack alert. Python does not support mutual imports, but 
XendDomainInfo
         # needs access to the XendDomain instance to look up domains. 
Attempting
@@ -290,7 +287,7 @@
             else:
                 self._delete_domain(d.id)
         if cleanup and do_domain_restarts:
-            self.scheduler.now(self.domain_restarts)
+            scheduler.now(self.domain_restarts)
 
     def update_domain(self, id):
         """Update the saved info for a domain.
@@ -506,7 +503,7 @@
                 timeout = min(timeout, shutdown.getTimeout())
         if self.shutdowns_by_id:
             # Pending shutdowns remain - reschedule.
-            self.scheduler.later(timeout, self.domain_shutdowns)
+            scheduler.later(timeout, self.domain_shutdowns)
 
     def domain_restart_schedule(self, id, reason, force=False):
         """Schedule a restart for a domain if it needs one.
diff -Nru a/tools/python/xen/xend/scheduler.py 
b/tools/python/xen/xend/scheduler.py
--- a/tools/python/xen/xend/scheduler.py        2005-05-18 15:02:23 -04:00
+++ b/tools/python/xen/xend/scheduler.py        2005-05-18 15:02:23 -04:00
@@ -1,29 +1,24 @@
 import threading
 
-class Scheduler:
+def later(delay, fn, args=(), kwargs={}):
+    """Schedule a function to be called later.
 
-    def later(self, _delay, _fn, args=(), kwargs={}):
-        """Schedule a function to be called later.
+    @param _delay: delay in seconds
+    @param _fn:    function
+    @param args:   arguments (list)
+    @param kwargs  keyword arguments (map)
+    """
+    timer = threading.Timer(delay, fn, args=args, kwargs=kwargs)
+    timer.start()
+    return timer
 
-        @param _delay: delay in seconds
-        @param _fn:    function
-        @param args:   arguments (list)
-        @param kwargs  keyword arguments (map)
-        """
-        runargs = [ _fn, args, kwargs ]
-        timer = threading.Timer(_delay, self._run, args=runargs)
-        timer.start()
+def now(fn, args=(), kwargs={}):
+    """Schedule a function to be called now.
 
-    def now(self, _fn, args=(), kwargs={}):
-        """Schedule a function to be called now.
-
-        @param _fn:    function
-        @param args:   arguments (list)
-        @param kwargs  keyword arguments (map)
-        """
-        runargs = [ _fn, args, kwargs ]
-        thread = threading.Thread(target=self._run, args=runargs)
-        thread.start()
-
-    def _run(self, fn, args, kwargs):
-        fn(*args, **kwargs)
+    @param _fn:    function
+    @param args:   arguments (list)
+    @param kwargs  keyword arguments (map)
+    """
+    thread = threading.Thread(target=fn, args=args, kwargs=kwargs)
+    thread.start()
+    return thread

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] XendDomain.py, scheduler.py:, BitKeeper Bot <=