> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Interruptible Sleep • AI Agent SDK

> interruptible_sleep: Sleep with periodic interruption checks.

# interruptible\_sleep

<div className="flex items-center gap-2">
  <Badge color="blue">Async</Badge>
  <Badge color="teal">Function</Badge>
</div>

> This function is defined in the [**retry\_utils**](../modules/retry_utils) module.

Sleep with periodic interruption checks.

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
async def interruptible_sleep(seconds: float, check_interval: float, interrupt_fn: Optional[Callable[[], bool]]) -> bool
```

## Parameters

<ParamField query="seconds" type="float" required={true}>
  Total sleep duration in seconds
</ParamField>

<ParamField query="check_interval" type="float" required={false} default="0.2">
  How often to check for interruption (seconds)
</ParamField>

<ParamField query="interrupt_fn" type="Optional" required={false}>
  Function that returns True if sleep should be interrupted
</ParamField>

### Returns

<ResponseField name="Returns" type="bool">
  True if completed full sleep, False if interrupted
</ResponseField>

## Usage

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
>>> interrupted = await interruptible_sleep(30.0, interrupt_fn=lambda: agent.is_stopped())
```

## Uses

* `interrupt_fn`
* `asyncio.sleep`

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/agent/retry_utils.py#L70">
  `praisonaiagents/agent/retry_utils.py` at line 70
</Card>
