'Acquire a cache lock for this tile.
Returns nothing, but blocks until the lock has been acquired.
Does nothing and returns immediately if `use_locks` is false.'

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

    if (not self.use_locks):
        return
    key_name = tile_key(layer, coord, format, self.path)
    due = (_time() + layer.stale_lock_timeout)
    while (_time() < due):
        if (not self.bucket.get_key((key_name + '-lock'))):
            break
        _sleep(0.2)
    key = self.bucket.new_key((key_name + '-lock'))
    key.set_contents_from_string('locked.', {'Content-Type': 'text/plain'}, reduced_redundancy=self.reduced_redundancy)
