diff --git a/tools/python/xen/web/reactor.py b/tools/python/xen/web/reactor.py index aa8e0c0646..1ebb5c84a0 100644 --- a/tools/python/xen/web/reactor.py +++ b/tools/python/xen/web/reactor.py @@ -1,9 +1,2 @@ -from threading import Timer - from unix import listenUNIX, connectUNIX from tcp import listenTCP, connectTCP - -def callLater(_delay, _fn, *args, **kwds): - timer = Timer(_delay, _fn, args=args, kwargs=kwds) - timer.start() - return timer diff --git a/tools/python/xen/xend/EventServer.py b/tools/python/xen/xend/EventServer.py index d9124570dd..ad0128aa06 100644 --- a/tools/python/xen/xend/EventServer.py +++ b/tools/python/xen/xend/EventServer.py @@ -5,8 +5,7 @@ import string from threading import Lock -#from twisted.internet import reactor -from xen.web import reactor +import scheduler # subscribe a.b.c h: map a.b.c -> h # subscribe a.b.* h: map a.b.* -> h @@ -130,7 +129,7 @@ class EventServer: self.lock.release() if async: - reactor.callLater(0, self.call_handlers, event, val) + scheduler.now(self.call_handlers, [event, val]) else: self.call_handlers(event, val) diff --git a/tools/python/xen/xend/XendMigrate.py b/tools/python/xen/xend/XendMigrate.py index e087475b9d..5264d68f5a 100644 --- a/tools/python/xen/xend/XendMigrate.py +++ b/tools/python/xen/xend/XendMigrate.py @@ -12,6 +12,7 @@ import types from xen.web import reactor from xen.web.protocol import Protocol, ClientFactory +import scheduler import sxp import XendDB import EventServer; eserver = EventServer.instance() @@ -120,7 +121,7 @@ class SuspendHandler: def start(self): self.subscribe(on=True) - timer = reactor.callLater(self.timeout, self.onTimeout) + timer = scheduler.later(self.timeout, self.onTimeout) try: self.readyCond.acquire() while not self.ready: diff --git a/tools/python/xen/xend/server/event.py b/tools/python/xen/xend/server/event.py index e0096d2d95..f16c786c3e 100644 --- a/tools/python/xen/xend/server/event.py +++ b/tools/python/xen/xend/server/event.py @@ -3,6 +3,7 @@ import StringIO from xen.web import reactor, protocol +from xen.xend import scheduler from xen.xend import sxp from xen.xend import PrettyPrint from xen.xend import EventServer; eserver = EventServer.instance() @@ -47,7 +48,7 @@ class EventProtocol(protocol.Protocol): if self.transport: self.transport.loseConnection() if self.connected: - reactor.callLater(0, self.connectionLost) + scheduler.now(self.connectionLost) def connectionLost(self, reason=None): self.unsubscribe()