CancellationToken

Symbolica documentation for getting started, symbolic expressions, numerical evaluation, pattern matching, and APIs in Python and Rust.

CancellationToken

class CancellationToken

A thread-safe signal for cancelling a long diagram-generation job.

Pass one token as cancellation_token and call cancel from a controlling thread when a large topology search should stop early.

Examples

from symbolica.community import hepkit as hep
token = hep.CancellationToken()
token.is_cancelled
False

Attributes

Name Description
is_cancelled Report whether cancellation has been requested.

is_cancelled

CancellationToken.is_cancelled: builtins.bool

Report whether cancellation has been requested.

Examples

Using the setup in the CancellationToken class example:

token = hep.CancellationToken()
token.cancel()
token.is_cancelled
True

Methods

Name Description
__new__ Create an independent token that can cancel a generation request.
cancel Mark this token as cancelled for all generation requests using it.

__new__

CancellationToken.__new__() -> CancellationToken

Create an independent token that can cancel a generation request.

Examples

Using the setup in the CancellationToken class example:

token = hep.CancellationToken()

cancel

CancellationToken.cancel() -> None

Mark this token as cancelled for all generation requests using it.

Examples

Using the setup in the CancellationToken class example:

token.cancel()