Returns an async context manager which must be used to create a new `Nursery`. It does not block on entry; on exit it blocks until all child tasks have exited. If no child tasks are running on exit, it will insert a schedule point (but no cancellation point) - equivalent to :fun
(
strict_exception_groups: bool | None = None,
)
| 1150 | |
| 1151 | |
| 1152 | def open_nursery( |
| 1153 | strict_exception_groups: bool | None = None, |
| 1154 | ) -> AbstractAsyncContextManager[Nursery]: |
| 1155 | """Returns an async context manager which must be used to create a |
| 1156 | new `Nursery`. |
| 1157 | |
| 1158 | It does not block on entry; on exit it blocks until all child tasks |
| 1159 | have exited. If no child tasks are running on exit, it will insert a |
| 1160 | schedule point (but no cancellation point) - equivalent to |
| 1161 | :func:`trio.lowlevel.cancel_shielded_checkpoint`. This means a nursery |
| 1162 | is never the source of a cancellation exception, it only propagates it |
| 1163 | from sub-tasks. |
| 1164 | |
| 1165 | Args: |
| 1166 | strict_exception_groups (bool): Unless set to False, even a single raised exception |
| 1167 | will be wrapped in an exception group. If not specified, uses the value passed |
| 1168 | to :func:`run`, which defaults to true. Setting it to False will be deprecated |
| 1169 | and ultimately removed in a future version of Trio. |
| 1170 | |
| 1171 | """ |
| 1172 | # only warn if explicitly set to falsy, not if we get it from the global context. |
| 1173 | if strict_exception_groups is not None and not strict_exception_groups: |
| 1174 | warn_deprecated( |
| 1175 | "open_nursery(strict_exception_groups=False)", |
| 1176 | version="0.25.0", |
| 1177 | issue=2929, |
| 1178 | instead=( |
| 1179 | "the default value of True and rewrite exception handlers to handle ExceptionGroups. " |
| 1180 | "See https://trio.readthedocs.io/en/stable/reference-core.html#designing-for-multiple-errors" |
| 1181 | ), |
| 1182 | use_triodeprecationwarning=True, |
| 1183 | ) |
| 1184 | |
| 1185 | if strict_exception_groups is None: |
| 1186 | strict_exception_groups = GLOBAL_RUN_CONTEXT.runner.strict_exception_groups |
| 1187 | |
| 1188 | return NurseryManager(strict_exception_groups=strict_exception_groups) |
| 1189 | |
| 1190 | |
| 1191 | @final |
no test coverage detected
searching dependent graphs…