Skip to content

Commit

Permalink
Use strict_exception_groups=False instead
Browse files Browse the repository at this point in the history
add test and news
  • Loading branch information
richardsheridan committed Jan 9, 2024
1 parent 1aa697e commit 81c08ac
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
1 change: 1 addition & 0 deletions newsfragments/397.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Minimum Trio version increased to 0.22.0 to use ``strict_exception_groups=False`` internally.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ classifiers =
packages = find:
include_package_data = True
install_requires =
trio >= 0.18.0
trio >= 0.22.0
outcome
attrs >= 17.3.0
cffi; os_name == 'nt' and implementation_name != 'pypy'
Expand Down
17 changes: 7 additions & 10 deletions trio_parallel/_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,22 @@ async def start(self):
self._child_recv_pipe.close()

# The following is mainly needed in the case of accidental recursive spawn
async def wait_for_ack():
async def wait_then_fail():
await self.wait()
raise BrokenWorkerProcessError("Worker failed to start", self.proc)

async with trio.open_nursery(strict_exception_groups=False) as nursery:
nursery.start_soon(wait_then_fail)
try:
code = await self._receive_chan.receive()
assert code == tp_workers.ACK
except BaseException:
self.kill()
with trio.CancelScope(shield=True):
await self.wait() # noqa: TRIO102
raise
assert code == tp_workers.ACK
nursery.cancel_scope.cancel()

exitcode = None
async with trio.open_nursery() as nursery:
nursery.start_soon(wait_for_ack)
exitcode = await self.wait()
nursery.cancel_scope.cancel()
if exitcode is not None:
raise BrokenWorkerProcessError("Worker failed to start", self.proc)

async def run_sync(self, sync_fn: Callable, *args) -> Optional[Outcome]:
try:
job = dumps((sync_fn, args), protocol=HIGHEST_PROTOCOL)
Expand Down
2 changes: 2 additions & 0 deletions trio_parallel/_tests/test_defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ def test_startup_failure_doesnt_hang(tmp_path):
)
assert not result.stdout
assert b"An attempt has been made to start a new process" in result.stderr
assert b"ExceptionGroup" not in result.stderr
assert b"MultiError" not in result.stderr
assert result.returncode


Expand Down

0 comments on commit 81c08ac

Please sign in to comment.