Improve visibility of exceptions in asyncio routines, especially within 'run_in_executor'
- Dominant language
- Python
- Stars
- 14
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
The following code stalled at the await future line:
```
def _validate_thread(self):
proc = subprocess.run('echo hello', shell=True)
print("This causes an exception: ", proc.returncode())
return proc.returncode
async def validate(self):
"""Verify that the system is running and ready to commit an update"""
self._logger.info("Starting Validate")
future = SharedLoop.run_in_executor(self._validate_thread)
print("started process")
self._logger.info("Waiting for validation to complete")
rc = await future
```
This is because of the exception in the print statement.
The error is visible while the tasks are being cleaned up during a CTRL+C, but can become somewhat lost in output among all the other cleanup that occurs.
Reporting the exception in real time (perhaps with a certain amount of -v's) would be very helpful, as would be raising the visibility of the error print during cleanup. I'd suggest printing the stack or coloring the line red.
Contributor guide
Assessment
This issue has not been assessed yet.