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

DOC: Order cancel_called after cancelled_caught #430

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
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
Next Next commit
DOC: Order cancel_called after cancelled_caught
and add a note that you mostly don't want to use cancel_called
smurfix committed Feb 10, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 85ba64f4779545769954fdd4e2b94b22918d699e
20 changes: 14 additions & 6 deletions docs/source/reference-core.rst
Original file line number Diff line number Diff line change
@@ -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
@@ -570,6 +564,20 @@ 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 this scope has been
cancelled, either by an explicit call to :meth:`cancel` or by
the deadline expiring.

.. note::

This attribute being True does *not* mean that the code within the
scope has been affected by the cancellation.

Thus, in most (if not all) cases you should use
:attr:'cancelled_caught` instead.

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