Skip to content

Commit

Permalink
Merge pull request #436 from njsmith/doc
Browse files Browse the repository at this point in the history
DOC: Order cancel_called after cancelled_caught
  • Loading branch information
njsmith authored Feb 14, 2018
2 parents f48d892 + b2ed7b4 commit 62f035f
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions docs/source/reference-core.rst
Original file line number Diff line number Diff line change
Expand Up @@ -556,12 +556,6 @@ Cancel scope objects provide the following interface:
This method is idempotent, i.e. if the scope was already
cancelled then this method silently does nothing.

.. attribute:: cancel_called

Readonly :class:`bool`. Records whether this scope has been
cancelled, either by an explicit call to :meth:`cancel` or by
the deadline expiring.

.. attribute:: cancelled_caught

Readonly :class:`bool`. Records whether this scope caught a
Expand All @@ -570,6 +564,24 @@ Cancel scope objects provide the following interface:
exception, and (2) this scope is the one that was responsible
for triggering this :exc:`~trio.Cancelled` exception.

.. attribute:: cancel_called

Readonly :class:`bool`. Records whether cancellation has been
requested for this scope, either by an explicit call to
:meth:`cancel` or by the deadline expiring.

This attribute being True does *not* necessarily mean that
the code within the scope has been, or will be, affected by
the cancellation. For example, if :meth:`cancel` was called
just before the scope exits, when it's too late to deliver
a :exc:`~trio.Cancelled` exception, then this attribute will
still be True.

This attribute is mostly useful for debugging and introspection.
If you want to know whether or not a chunk of code was actually
cancelled, then :attr:`cancelled_caught` is usually more
appropriate.

Trio also provides several convenience functions for the common
situation of just wanting to impose a timeout on some code:

Expand Down

0 comments on commit 62f035f

Please sign in to comment.