[svn r62984] allow for host to go down if it didn't go up yet

--HG--
branch : trunk
This commit is contained in:
hpk 2009-03-17 08:19:23 +01:00
parent 3815c1afc9
commit 009ac242c6
2 changed files with 7 additions and 2 deletions

View File

@ -170,7 +170,11 @@ class DSession(Session):
self.host2pending[host] = [] self.host2pending[host] = []
def removehost(self, host): def removehost(self, host):
try:
pending = self.host2pending.pop(host) pending = self.host2pending.pop(host)
except KeyError:
# this happens if we didn't receive a hostup event yet
return []
for item in pending: for item in pending:
del self.item2host[item] del self.item2host[item]
return pending return pending

View File

@ -47,7 +47,8 @@ class TestDSession:
pending = session.removehost(host) pending = session.removehost(host)
assert pending == [item] assert pending == [item]
assert item not in session.item2host assert item not in session.item2host
py.test.raises(Exception, "session.removehost(host)") l = session.removehost(host)
assert not l
def test_senditems_removeitems(self, testdir): def test_senditems_removeitems(self, testdir):
item = testdir.getitem("def test_func(): pass") item = testdir.getitem("def test_func(): pass")