[svn r38109] bailing out the optimize_localhost approach

to consider it differently

--HG--
branch : trunk
This commit is contained in:
hpk 2007-02-07 20:36:41 +01:00
parent d614e67fb1
commit f07e482ddb
2 changed files with 9 additions and 41 deletions

View File

@ -106,8 +106,7 @@ class HostRSync(py.execnet.RSync):
return remotepath return remotepath
class HostManager(object): class HostManager(object):
def __init__(self, config, hosts=None, optimise_localhost=False): def __init__(self, config, hosts=None):
self.optimise_localhost = optimise_localhost
self.config = config self.config = config
if hosts is None: if hosts is None:
hosts = self.config.getvalue("dist_hosts") hosts = self.config.getvalue("dist_hosts")
@ -133,21 +132,14 @@ class HostManager(object):
rsync = HostRSync(ignores=ignores, rsync = HostRSync(ignores=ignores,
verbose=self.config.option.verbose) verbose=self.config.option.verbose)
destrelpath = root.relto(self.config.topdir) destrelpath = root.relto(self.config.topdir)
to_send = False
for host in self.hosts: for host in self.hosts:
if host.hostname != 'localhost' or not self.optimise_localhost: def donecallback(host, root):
def donecallback(host=host, root=root):
reporter(repevent.HostRSyncRootReady(host, root))
remotepath = rsync.add_target_host(
host, reporter, destrelpath, finishedcallback=
donecallback)
reporter(repevent.HostRSyncing(host, root, remotepath))
to_send = True
else:
reporter(repevent.HostRSyncRootReady(host, root)) reporter(repevent.HostRSyncRootReady(host, root))
if to_send: remotepath = rsync.add_target_host(
# don't send if we have no targets host, reporter, destrelpath, finishedcallback=
rsync.send(root) lambda host=host, root=root: donecallback(host, root))
reporter(repevent.HostRSyncing(host, root, remotepath))
rsync.send(root)
def setup_hosts(self, reporter): def setup_hosts(self, reporter):
self.init_rsync(reporter) self.init_rsync(reporter)
@ -161,14 +153,7 @@ class HostManager(object):
def teardown_hosts(self, reporter, channels, nodes, def teardown_hosts(self, reporter, channels, nodes,
waiter=lambda : time.sleep(.1), exitfirst=False): waiter=lambda : time.sleep(.1), exitfirst=False):
for channel in channels: for channel in channels:
try: channel.send(None)
channel.send(None)
except IOError:
print "Sending error, channel IOError"
print channel._getremoterror()
# XXX: this should go as soon as we'll have proper detection
# of hanging nodes and such
raise
clean = exitfirst clean = exitfirst
while not clean: while not clean:
@ -181,11 +166,7 @@ class HostManager(object):
def kill_channels(self, channels): def kill_channels(self, channels):
for channel in channels: for channel in channels:
try: channel.send(42)
channel.send(42)
except IOError:
print "Sending error, channel IOError"
print channel._getremoterror()
def teardown_gateways(self, reporter, channels): def teardown_gateways(self, reporter, channels):
for channel in channels: for channel in channels:

View File

@ -192,19 +192,6 @@ class TestHostManager(DirSetup):
assert self.dest.join("dir5","file").check() assert self.dest.join("dir5","file").check()
assert not self.dest.join("dir6").check() assert not self.dest.join("dir6").check()
def test_hostmanager_rsync_optimise_localhost(self):
dir1 = self.source.ensure("opt_localhost1", dir=1)
config = py.test.config._reparse([self.source])
hm = HostManager(config,
hosts=[HostInfo("localhost:" + str(self.dest))],
optimise_localhost=True)
events = []
hm.init_rsync(reporter=events.append)
rr = [i for i in events if isinstance(i, repevent.HostRSyncRootReady)]
assert len(rr) == 1
hr = [i for i in events if isinstance(i, repevent.HostRSyncing)]
assert len(hr) == 0
def test_getpath_relto_home(): def test_getpath_relto_home():
x = getpath_relto_home("hello") x = getpath_relto_home("hello")
assert x == py.path.local._gethomedir().join("hello") assert x == py.path.local._gethomedir().join("hello")