Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add state graph (using mermaid) to the discussion page #1208

Merged
merged 5 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"sphinxcontrib.programoutput",
"sphinx_github_changelog",
"sphinx_copybutton",
"sphinxcontrib.mermaid",
"procrastinate.contrib.sphinx",
]

Expand Down Expand Up @@ -98,6 +99,13 @@

html_favicon = "favicon.ico"

mermaid_init_js = """
mermaid.initialize({
startOnLoad: true,
theme: "neutral"
});
"""

# -- Options for sphinx.ext.autodoc ------------------------------------------

autodoc_typehints = "both"
Expand Down
35 changes: 35 additions & 0 deletions docs/discussions.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,41 @@ For a more practical approach, see {doc}`howto/advanced/locks`.

(discussion-async)=

## What are the different states of a Job and how do they go from one to another?

A job can be in one of the following states:

```{mermaid}
flowchart LR
START:::hidden
todo[TODO]
doing[DOING]
succeeded[SUCCEEDED]
failed[FAILED]
cancelled[CANCELLED]
aborted[ABORTED]
START -- a --> todo
todo -- b --> doing
doing -- c --> succeeded
doing -- d --> todo
doing -- e --> failed
todo -- f --> cancelled
doing -- g --> aborted
classDef hidden display: none;
```

- **a**: The job was deferred by `my_task.defer()` (or the async equivalent)
- **b**: A worker fetched the job from the database and started processing it
- **c**: A worker finished processing a job successfully
- **d**: The job failed by raising an error but will be retried
- **e**: The job failed by raising an error and won't be retried
- **f**: The job was cancelled by calling `job_manager.cancel_job_by_id(job_id)` (or the async equivalent) before its processing was started
- **g**: The job was aborted during being processed by calling
`job_manager.cancel_job_by_id(job_id, abort=True)` (or the async equivalent). A sync job must also
handle the abort request by checking `context.should_abort()` and raising a
`JobAborted` exception. An async job handles it automatically by internally raising a
`CancelledError` exception.

## Asynchronous operations & concurrency

Here, asynchronous (or async) means "using the Python `async/await` keywords, to
Expand Down
13 changes: 12 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ Sphinx = "*"
sphinx-copybutton = "*"
sphinx-github-changelog = "*"
sphinxcontrib-programoutput = "*"
sphinxcontrib-mermaid = "*"
myst-parser = "*"

[tool.poetry-dynamic-versioning]
Expand Down
Loading