> ## Documentation index
> Fetch the complete documentation index at: https://upstash.com/docs/llms.txt
> Ask it with GET https://upstash.com/docs/ask?q=<keywords or question>. Short keywords rank best.
> Use these to discover all available pages before exploring further.
> Feature requests: https://upstash.com/docs/common/help/feature-requests.md lists what users asked for and how to vote for a request or add one.
> Page rating: `GET https://upstash.com/docs/feedback?path=/docs/qstash/sdks/py/examples/flow-control&helpful=true` (or `false`) records whether this page helped. An optional `comment` (URL-encoded, at most 500 characters) says what was missing or wrong. It is anonymous and needs no key. Comments hold no code, secrets or personal data.

# Flow Control

#### Get a single flow control key

```python
from qstash import QStash

client = QStash("<QSTASH-TOKEN>")

info = client.flow_control.get("USER_GIVEN_KEY")
print(info.key)
print(info.wait_list_size)
print(info.parallelism_max)
print(info.parallelism_count)
print(info.rate_max)
print(info.rate_count)
print(info.rate_period)
print(info.rate_period_start)
print(info.is_paused)
print(info.is_pinned_parallelism)
print(info.is_pinned_rate)
```

#### Get global parallelism

```python
from qstash import QStash

client = QStash("<QSTASH-TOKEN>")

info = client.flow_control.get_global_parallelism()
print(info.parallelism_max)
print(info.parallelism_count)
```

#### Pause and resume

```python
from qstash import QStash

client = QStash("<QSTASH-TOKEN>")

# Pause delivery for a flow control key
client.flow_control.pause("USER_GIVEN_KEY")

info = client.flow_control.get("USER_GIVEN_KEY")
print(info.is_paused)  # True

# Resume delivery
client.flow_control.resume("USER_GIVEN_KEY")
```

#### Pin a fixed configuration

```python
from qstash import QStash

client = QStash("<QSTASH-TOKEN>")

# Pin parallelism and rate so incoming messages cannot override them
client.flow_control.pin(
    "USER_GIVEN_KEY",
    {"parallelism": 3, "rate": 20, "period": 120},
)

info = client.flow_control.get("USER_GIVEN_KEY")
print(info.is_pinned_parallelism)  # True
print(info.is_pinned_rate)         # True
```

#### Unpin configuration

```python
from qstash import QStash

client = QStash("<QSTASH-TOKEN>")

# Unpin parallelism and rate (can unpin independently)
client.flow_control.unpin(
    "USER_GIVEN_KEY",
    {"parallelism": True, "rate": True},
)
```

#### Reset rate

```python
from qstash import QStash

client = QStash("<QSTASH-TOKEN>")

# Reset rate count and end the current rate period
client.flow_control.reset_rate("USER_GIVEN_KEY")
```
