---
title: "lock or wait · RUAL Documentation"
description: "Sets a lock or waits until the lock has been released."
canonical: https://docs.rual.nl/block-types/locking/function_claim_lock_wait
language: en
---

# lock or wait

This block is part of the [`locking`](https://docs.rual.nl/block-types/locking) group and was last modified in core [`v15.0.0`](https://docs.rual.nl/core-versions/150000).

Sets a lock or waits until the lock has been released.

- flow `flow`

- key required `value`

- expiry (sec.) required `number`

- auto clear `v15.0.0` `condition` Release this lock automatically when the flow ends : no separate free lock block needed.

- flow `flow`

The critical-section shape: a [function trigger](https://docs.rual.nl/block-types/globals/trigger_custom_function) runs the flow, [lock or wait](https://docs.rual.nl/block-types/locking/function_claim_lock_wait) claims the key (waiting when another request holds it), the document is read with [get document](https://docs.rual.nl/block-types/storage/function_get_document) and written with [update document](https://docs.rual.nl/block-types/storage/function_update_document_mutations), and a [funnel](https://docs.rual.nl/block-types/funnels/funnel) merges the paths so [free lock](https://docs.rual.nl/block-types/locking/function_claim_unlock) always releases the key.

![Studio canvas example for the lock or wait block: lock around a document update.](https://docs.rual.nl/canvas-examples/function_claim_lock_wait.png)

### Commonly used with

In production blueprints, this block is most often wired together with:

- [search single](https://docs.rual.nl/block-types/storage/function_search_single_result): this block feeds into it. searches in the given storage based on a query and returns maximum one result.

- [number](https://docs.rual.nl/block-types/number/number_default): feeds into this block. Generates a valid number from the filled custom value in the blueprint.

- [concatenate values](https://docs.rual.nl/block-types/value/value_concatenate): feeds into this block.

- [branch](https://docs.rual.nl/block-types/flow/branch): feeds into this block.

- [execute](https://docs.rual.nl/block-types/function%20execution/function_custom_execute): this block feeds into it. Executes the given funcion and waits for it to be executed.

- [funnel](https://docs.rual.nl/block-types/funnels/funnel): feeds into this block.

### Used in these guides

These documentation pages use or explain this block:

- [Block Execution](https://docs.rual.nl/blueprints/block-execution)

- [Locking and Concurrency](https://docs.rual.nl/blueprints/locking)

- [Storage Events](https://docs.rual.nl/blueprints/storage-events)

### Version history

Introduced in [`v15.0.0`](https://docs.rual.nl/core-versions/150000).
