Commit 58ba1765 authored by Kirill Smelkov's avatar Kirill Smelkov

context: Note that a context has to be explicitly canceled to release resources

Same story as in Go, but we were lacking documentation notice about this.
parent 9c260fde
...@@ -66,6 +66,9 @@ deadlineExceeded = RuntimeError("deadline exceeded") ...@@ -66,6 +66,9 @@ deadlineExceeded = RuntimeError("deadline exceeded")
# #
# Returned context inherits from parent and in particular is canceled when # Returned context inherits from parent and in particular is canceled when
# parent is done. # parent is done.
#
# The caller should explicitly call cancel to release context resources as soon
# the context is no longer needed.
def with_cancel(parent): # -> ctx, cancel def with_cancel(parent): # -> ctx, cancel
ctx = _CancelCtx(parent) ctx = _CancelCtx(parent)
return ctx, ctx._cancel return ctx, ctx._cancel
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment