'Set the state inside of the lock - there are multiple threads who set state here'

def setMuninHostState(self, hostname, state):

    if (state is None):
        return
    stateData = bson.binary.Binary(zlib.compress(bson.BSON.encode(state, check_keys=False), 9))
    try:
        self.hostStateLock.acquire()
        for hostKey in self.hostState.keys():
            if (hostname == self.extractHostname(hostKey)):
                state['port'] = self.extractPort(hostKey)
                self._setHostStateValue(hostKey, 'munin', stateData)
    finally:
        self.hostStateLock.release()
