---
title: "Idle Timer"
description: "This pattern was formerly called Inactiveness Tracker Timer."
canonical_url: "https://docs.superdurable.io/design-patterns/external-interaction/idle-timer/"
source: "docs/content/design-patterns/external-interaction/idle-timer.mdx"
locale: "en"
language: "python"
---

> Index of every page for AI agents: https://docs.superdurable.io/llms.txt

# Idle Timer

Code on this page is in Python. Other languages: [Go](https://docs.superdurable.io/design-patterns/external-interaction/idle-timer.go.md) · [Java](https://docs.superdurable.io/design-patterns/external-interaction/idle-timer.java.md) · [TypeScript](https://docs.superdurable.io/design-patterns/external-interaction/idle-timer.typescript.md) · [Rust](https://docs.superdurable.io/design-patterns/external-interaction/idle-timer.rust.md)

This pattern was formerly called Inactiveness Tracker Timer.

Use this pattern when an action should happen only after a period without activity. `InactivenessTrackerFlow` starts with `TrackerStep`. It waits for either the Timer or the **Active** Channel. If activity arrives first, `TrackerStep` moves to itself, which starts a new Timer. If the Timer fires first, the Flow moves to `ProcessInactiveness`.

**Flow graph: InactivenessTrackerFlow**

**Steps**

1. `Tracker` (start Step): Restart the timer on each activity and continue when the timer fires first. Next: `ProcessInactiveness`, or `Tracker` again.
2. `ProcessInactiveness`: Handle a period without activity and complete. Next: the Flow completes.

**RPCs**

- `record_activity`: Publishes to `Active`.

Example: [examples/python/dex_examples/patterns/inactiveness-tracker-timer/inactiveness_tracker_flow.py](https://github.com/superdurable/dex/tree/main/examples/python/dex_examples/patterns/inactiveness-tracker-timer/inactiveness_tracker_flow.py)

## Core Step

**Python**

```python
class TrackerStep(Step[None]):
    def __init__(self, process_inactiveness: ProcessInactiveness, active_channel: Channel[None]) -> None:
        self.process_inactiveness = process_inactiveness
        self.active_channel = active_channel

    def wait_for(self, context: Context, input: None) -> Wait:
        del context, input
        return Wait.any_of(Timer.by_duration(TRACKER_DURATION), self.active_channel.for_one())

    def execute(self, context: Context, input: None) -> StepDecision:
        del input
        if context.has_timer_fired():
            return go_to(ProcessInactiveness, None)
        return go_to(TrackerStep, None)
```

Example: [examples/python/dex_examples/patterns/inactiveness-tracker-timer/inactiveness_tracker_flow.py](https://github.com/superdurable/dex/tree/main/examples/python/dex_examples/patterns/inactiveness-tracker-timer/inactiveness_tracker_flow.py)

## Next

- [Idle Timer with Resolution](https://docs.superdurable.io/design-patterns/external-interaction/idle-timer-with-resolution.md)
- [Timer](https://docs.superdurable.io/concepts/primitives/timer.md)
- [Channel](https://docs.superdurable.io/concepts/primitives/channel.md)
