Skip to content

Commit

Permalink
update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
onlyann committed Sep 8, 2024
1 parent f9bf4e7 commit 229e086
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions docs/howto/advanced/cancellation.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ When a job is requested to abort and that job fails, it will not be retried (reg

## Handle an abortion request inside the task

## Sync tasks
### Sync tasks

In a sync task, we can check (for example, periodically) if the task should be
aborted. If we want to respect that abortion request (we don't have to), we raise a
Expand All @@ -63,10 +63,9 @@ def my_task(context):
do_something_expensive()
```

# Async tasks
### Async tasks

For async tasks (coroutines), the async taks will be cancelled via [asyncio cancellation](https://docs.python.org/3/library/asyncio-task.html#task-cancellation) mechasnism.
As such, the task will be cancelled at the next opportunity.
For async tasks (coroutines), they are cancelled via the [asyncio cancellation](https://docs.python.org/3/library/asyncio-task.html#task-cancellation) mechasnism.

```python
@app.task()
Expand All @@ -76,7 +75,7 @@ async def my_task():
await do_something()
```

It is possible to prevent the job from aborting by capturing asyncio.CancelledError.
It is possible to prevent the job from aborting by capturing asyncio.CancelledError.

```python
@app.task()
Expand Down

0 comments on commit 229e086

Please sign in to comment.