Skip to content

Commit

Permalink
nit
Browse files Browse the repository at this point in the history
  • Loading branch information
richardsheridan committed Dec 25, 2024
1 parent 18569b8 commit fbc5ab3
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions trio_parallel/_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,16 +271,10 @@ def configure_default_context(
DEFAULT_CONTEXT = ctx


async def close_at_run_end(ctx):
try:
await trio.sleep_forever()
finally:
await ctx._aclose() # noqa: ASYNC102


CACHE_SCOPE_TREEVAR = tricycle.TreeVar("tp_cache_scope")

if sys.platform == "win32":
DEFAULT_CONTEXT_RUNVAR = trio.lowlevel.RunVar("win32_ctx")
DEFAULT_CONTEXT_RUNVAR = trio.lowlevel.RunVar("tp_win32_ctx")
DEFAULT_CONTEXT_PARAMS = {}

def get_default_context():
Expand All @@ -297,6 +291,12 @@ def get_default_context():
DEFAULT_CONTEXT_RUNVAR.set(ctx)
return ctx

async def close_at_run_end(ctx):
try:
await trio.sleep_forever()
finally:
await ctx._aclose() # noqa: ASYNC102

else:

def get_default_context():
Expand Down Expand Up @@ -390,7 +390,8 @@ async def cache_scope(
worker_type=WorkerType.SPAWN,
):
"""
Override the configuration of `trio_parallel.run_sync()` in this and all subtasks.
Override the configuration of `trio_parallel.run_sync()` in this task and all
subtasks.
The context will automatically wait for any running workers to become idle when
exiting the scope. Since this wait cannot be cancelled, it is more convenient to
Expand Down

0 comments on commit fbc5ab3

Please sign in to comment.