tornadoweb / tornadoweb/tornado
`Subprocess.wait_for_exit` never resolves if process terminated before it is called
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 22.2k
- Forks
- 5.6k
- Avg merge
- 3h 42m
- Merged PRs (30d)
- 16
Description
The wait_for_exit method eventually calls os.waitpid, which throws a ChildProcessError if no process with the specified pid exists. This exception is caught, the function just returns, and the Future never resolves.
if __name__ == '__main__':
import asyncio
from tornado.process import Subprocess
async def f():
p = Subprocess("ls")
p.proc.wait()
return await p.wait_for_exit()
loop = asyncio.get_event_loop()
loop.run_until_complete(f())
Instead, the process could be retrieved from the _waiting dict and the return code could be accessed from the object directly.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in tornado/process.py at Subprocess.wait_for_exit and inspect how os.waitpid errors are handled and how the _waiting dictionary stores processes. Reproduce the example, then make the Future resolve when the process terminated before wait_for_exit was called, using the available return code.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100