'Acquire a cache lock for this tile.
Returns nothing, but blocks until the lock has been acquired.'

def lock(self, layer, coord, format):

    mem = Client(self.servers)
    key = tile_key(layer, coord, format, self.revision, self.key_prefix)
    due = (_time() + layer.stale_lock_timeout)
    try:
        while (_time() < due):
            if mem.add((key + '-lock'), 'locked.', layer.stale_lock_timeout):
                return
            _sleep(0.2)
        mem.set((key + '-lock'), 'locked.', layer.stale_lock_timeout)
        return
    finally:
        mem.disconnect_all()
