Skip to content

Commit 190a0f9

Browse files
committed
Tutorial: improve section on exceptions.
1 parent 9907322 commit 190a0f9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

TUTORIAL.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -959,8 +959,10 @@ in a loop. The coro `asyn.sleep` [supports this](./PRIMITIVES.md#41-coro-sleep).
959959

960960
Where an exception occurs in a coro, it should be trapped either in that coro
961961
or in a coro which is awaiting its completion. This ensures that the exception
962-
is not propagated to the scheduler. If this occurred it would stop running,
963-
passing the exception to the code which started the scheduler.
962+
is not propagated to the scheduler. If this occurred the scheduler would stop
963+
running, passing the exception to the code which started the scheduler.
964+
Consequently, to avoid stopping the scheduler, coros launched with
965+
`loop.create_task()` must trap any exceptions internally.
964966

965967
Using `throw` or `close` to throw an exception to a coro is unwise. It subverts
966968
`uasyncio` by forcing the coro to run, and possibly terminate, when it is still

0 commit comments

Comments
 (0)