# hold_session_lock

> **Function** in `deepagents_code`

📖 [View in docs](https://reference.langchain.com/python/deepagents-code/_session_lock/hold_session_lock)

Register this process as a running session for its lifetime.

Idempotent and fail-soft: when the lock cannot be taken, the process runs
unregistered and `is_sole_session` reports `False`. The descriptor is
non-inheritable, so the re-exec after an update drops it and the new
process registers itself again.

## Signature

```python
hold_session_lock() -> None
```

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/6a8d452d70f9bcb978e6bd44831dda093ecbe928/libs/code/deepagents_code/_session_lock.py#L57)