xen-vtx-unstable

annotate tools/python/xen/xend/scheduler.py @ 6774:4d899a738d59

merge?
author cl349@firebug.cl.cam.ac.uk
date Tue Sep 13 15:05:49 2005 +0000 (2005-09-13)
parents dd668f7527cb 64d6de1ea743
children e7c7196fa329 8ca0f98ba8e2
rev   line source
kaf24@6064 1 #============================================================================
kaf24@6064 2 # This library is free software; you can redistribute it and/or
kaf24@6064 3 # modify it under the terms of version 2.1 of the GNU Lesser General Public
kaf24@6064 4 # License as published by the Free Software Foundation.
kaf24@6064 5 #
kaf24@6064 6 # This library is distributed in the hope that it will be useful,
kaf24@6064 7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
kaf24@6064 8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
kaf24@6064 9 # Lesser General Public License for more details.
kaf24@6064 10 #
kaf24@6064 11 # You should have received a copy of the GNU Lesser General Public
kaf24@6064 12 # License along with this library; if not, write to the Free Software
kaf24@6064 13 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
kaf24@6064 14 #============================================================================
kaf24@6064 15 # Copyright (C) 2004, 2005 Mike Wray <mike.wray@hp.com>
kaf24@6064 16 #============================================================================
kaf24@6064 17
mjw@4580 18 import threading
mjw@4580 19
cl349@4992 20 def later(delay, fn, args=(), kwargs={}):
cl349@4992 21 """Schedule a function to be called later.
mjw@4580 22
ewan@6766 23 @param delay: delay in seconds
ewan@6766 24 @param fn: function
cl349@4992 25 @param args: arguments (list)
cl349@4992 26 @param kwargs keyword arguments (map)
cl349@4992 27 """
cl349@4992 28 timer = threading.Timer(delay, fn, args=args, kwargs=kwargs)
cl349@4992 29 timer.start()
cl349@4992 30 return timer
mjw@4617 31
cl349@4992 32 def now(fn, args=(), kwargs={}):
cl349@4992 33 """Schedule a function to be called now.
mjw@4617 34
ewan@6766 35 @param fn: function
cl349@4992 36 @param args: arguments (list)
cl349@4992 37 @param kwargs keyword arguments (map)
cl349@4992 38 """
cl349@4992 39 thread = threading.Thread(target=fn, args=args, kwargs=kwargs)
cl349@4992 40 thread.start()
cl349@4992 41 return thread