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

Wait for proc to reach EXECUTING state before yielding #24

Closed gsalgado closed 4 years ago

gsalgado commented 4 years ago

What was wrong?

open_in_process() yielded as soon as the sub process reached the STARTED state, which is before the signal handlers have been setup, so a signal sent immediately after open_in_process() yielded would not be properly handled

How was it fixed?

Wait for proc to reach EXECUTING state before yielding. Also use a timeout when waiting so that we don't hang forever in case the process never reaches that state.

gsalgado commented 4 years ago

@pipermerriam added a new commit with more tests, and they exposed the need to kill the subproc when there's a timeout in open_in_process()

pipermerriam commented 4 years ago

I don't know if it is helpful but, assuming this is an async generator issue, you might look at the code snippet in this comment:

https://github.com/python-trio/trio/issues/638#issuecomment-431954073