ethereum / asyncio-run-in-process

A simple asyncio friendly replacement for multiprocessing to run coroutines in a separate process.
MIT License
13 stars 9 forks source link

A couple changes related to task/child cancellation #13

Closed gsalgado closed 4 years ago

gsalgado commented 4 years ago
  1. When the task running open_in_process() is cancelled, we now send a SIGINT and give the child a chance to terminate before sending a SIGTERM.
  2. When a child raises asyncio.CancelledError, that gets converted into a ChildCancelled exception

Also renames Process.@result to Process.get_result_or_raise() as having a property that is expected to raise an exception is at the very least unexpected.

gsalgado commented 4 years ago

With this change we'll be able to get rid of some trinity code that does the same thing (https://github.com/ethereum/trinity/blob/00dc1a032851ef830ab04cedc4ce39070c83b18a/trinity/extensibility/asyncio.py#L37-L51), thus consolidating the handling of child termination and avoiding double sigints/sigterms like the one I was trying to fix in https://github.com/ethereum/trinity/pull/1610