[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
class HostManager(object):
def __init__(self, config, hosts=None, optimise_localhost=False):
self.optimise_localhost = optimise_localhost
def __init__(self, config, hosts=None):
self.config = config
if hosts is None:
hosts = self.config.getvalue("dist_hosts")
@ -133,21 +132,14 @@ class HostManager(object):
rsync = HostRSync(ignores=ignores,
verbose=self.config.option.verbose)
destrelpath = root.relto(self.config.topdir)
to_send = False
for host in self.hosts:
if host.hostname != 'localhost' or not self.optimise_localhost:
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:
def donecallback(host, root):
reporter(repevent.HostRSyncRootReady(host, root))
if to_send:
# don't send if we have no targets
rsync.send(root)
remotepath = rsync.add_target_host(
host, reporter, destrelpath, finishedcallback=
lambda host=host, root=root: donecallback(host, root))
reporter(repevent.HostRSyncing(host, root, remotepath))
rsync.send(root)
def setup_hosts(self, reporter):
self.init_rsync(reporter)
@ -161,14 +153,7 @@ class HostManager(object):
def teardown_hosts(self, reporter, channels, nodes,
waiter=lambda : time.sleep(.1), exitfirst=False):
for channel in channels:
try:
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
channel.send(None)
clean = exitfirst
while not clean:
@ -181,11 +166,7 @@ class HostManager(object):
def kill_channels(self, channels):
for channel in channels:
try:
channel.send(42)
except IOError:
print "Sending error, channel IOError"
print channel._getremoterror()
channel.send(42)
def teardown_gateways(self, reporter, channels):
for channel in channels:

View File

@ -192,19 +192,6 @@ class TestHostManager(DirSetup):
assert self.dest.join("dir5","file").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():
x = getpath_relto_home("hello")
assert x == py.path.local._gethomedir().join("hello")