Try to identify out of memory errors and print corresponding error message#58
Try to identify out of memory errors and print corresponding error message#58pagmatt wants to merge 9 commits into
Conversation
DvdMgr
left a comment
There was a problem hiding this comment.
Left a few comments. Once we address these it should be good to go!
| print(error_message) | ||
| print(error_message) |
| stderr_file.read(), | ||
| stdout_file.read())) | ||
| if return_code == SIGKILL_CODE: | ||
| error_message = '\nSimulation likely killed due to an out of memory error.\n' + \ |
There was a problem hiding this comment.
Let's not sound too confident about why the process was killed! How about:
"Simulation was killed. Possible causes may include an out of memory error."
There was a problem hiding this comment.
That's definitively better, you are right
| from typing import Final | ||
|
|
||
| SIGKILL_CODE: Final = -9 # POSIX return code which usually corresponds to out of memory events. |
There was a problem hiding this comment.
Is it necessary to import typing.Final here? We don't use typing anywhere else in the project.
There was a problem hiding this comment.
It is not necessary, it just seemed "good practice" to use it for marking the variable (almost) as a constant. At least, that was my understanding from the PEP guideline which I linked above. If you prefer to limit the imports though I can remove it!
| % (parameter, | ||
| stderr_file.read(), | ||
| stdout_file.read())) | ||
| if return_code == SIGKILL_CODE: |
There was a problem hiding this comment.
May be worth it to always print return_code when it's not 0, even when it's not exactly -9. Can you add this information to the common_error_message?
This PR aims to identify simulation crashes due to out of memory errors. Indeed, in these cases the simulation script is terminated by the kernel with signal
SIGKILL(on POSIX systems), and no errors are shown in eitherstdoutorstderr. Instead, with these changes the user will be informed of the likely cause of the crash.P.S. I could not find a definition of the
SIGKILLreturn code in any Python module, so I not-so-elegantly defined it myself. The syntax is taken from this PEP "guideline". Feel free to propose a different approach if a more elegant solutions comes to mind :)