Skip to content

Commit

Permalink
Add kill switches to the example on the home page
Browse files Browse the repository at this point in the history
  • Loading branch information
dominictarro committed Apr 19, 2024
1 parent c7b7915 commit b41ebfa
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,21 @@ Break `Task.map` into smaller concurrent [batches](./concurrency/batch_task.md).

```python
from prefect import flow, task
from prefecto.concurrency import BatchTask
from prefecto.concurrency import BatchTask, CountSwitch

@task
def task(x):
print(x)
def my_task(x):
if x % 100 == 0:
raise ValueError(f"{x} is divisible by 100.")
return x

@flow
def flow():
results = BatchTask(task, size=100).map(range(1000))
def my_flow():
results = BatchTask(
my_task,
size=100,
kill_switch=CountSwitch(15),
).map(range(1000))

```

Expand Down

0 comments on commit b41ebfa

Please sign in to comment.