Open NightMachinery opened 1 year ago
@gruns Can you merge this in? I just had another run interrupted because I was editing the source code of my program (while the code was running) and icecream
fails if it cannot parse the source code.
File ~/micromamba/envs/p310/lib/python3.10/site-packages/icecream/icecream.py:208 in __call__
out = self._format(callFrame, *args)
File ~/micromamba/envs/p310/lib/python3.10/site-packages/icecream/icecream.py:242 in _format
out = self._formatArgs(
File ~/micromamba/envs/p310/lib/python3.10/site-packages/icecream/icecream.py:249 in _formatArgs
sanitizedArgStrs = [
File ~/micromamba/envs/p310/lib/python3.10/site-packages/icecream/icecream.py:250 in <listcomp>
source.get_text_with_indentation(arg)
File ~/micromamba/envs/p310/lib/python3.10/site-packages/icecream/icecream.py:120 in get_text_with_indentation
result = self.asttokens().get_text(node)
File ~/micromamba/envs/p310/lib/python3.10/site-packages/executing/executing.py:443 in asttokens
self._asttokens = self.asttext().asttokens
File ~/micromamba/envs/p310/lib/python3.10/site-packages/asttokens/asttokens.py:329 in asttokens
tree=self.tree,
File ~/micromamba/envs/p310/lib/python3.10/site-packages/asttokens/asttokens.py:319 in tree
self._tree = ast.parse(self._text, self._filename)
File ~/micromamba/envs/p310/lib/python3.10/ast.py:50 in parse
return compile(source, filename, mode, flags,
File ~/code/DecompV/decompv/x/ds/utils.py:2373
else:
^
IndentationError: expected an indented block after 'elif' statement on line 2370
When using
icecream
withmultiprocessing
, I had this exception. So I simply added a try-catch-print to Icecream to avoid breaking the program when something unexpected happens, as the results of the print are for debugging purposes and don't change program behavior anyway.This exception interrupted a longrunning computation, so I believe my PR is quite useful.