'sys.exit() triggers TypeError: object of type 'NoneType' has no len() error
I can not make my script stop. I've tried sys.exit () as well as os._exit()
I have a bit of the code:
try:
report = func_timeout(config.timeout_time, load_the_report, args=(download_id, config))
except FunctionTimedOut:
print(f"timeout error for the {config.name} {config.date}")
print('####')
sys.exit()
sys.exit () gives an error :
SystemExit:
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
[... skipping hidden 1 frame]
/opt/conda/lib/python3.9/site-packages/IPython/core/interactiveshell.py in showtraceback(self, exc_tuple, filename, tb_offset, exception_only, running_compiled_code)
2055 stb = ['An exception has occurred, use %tb to see '
2056 'the full traceback.\n']
-> 2057 stb.extend(self.InteractiveTB.get_exception_only(etype,
2058 value))
2059 else:
/opt/conda/lib/python3.9/site-packages/IPython/core/ultratb.py in get_exception_only(self, etype, value)
752 value : exception value
753 """
--> 754 return ListTB.structured_traceback(self, etype, value)
755
756 def show_exception_only(self, etype, evalue):
/opt/conda/lib/python3.9/site-packages/IPython/core/ultratb.py in structured_traceback(self, etype, evalue, etb, tb_offset, context)
627 chained_exceptions_tb_offset = 0
628 out_list = (
--> 629 self.structured_traceback(
630 etype, evalue, (etb, chained_exc_ids),
631 chained_exceptions_tb_offset, context)
/opt/conda/lib/python3.9/site-packages/IPython/core/ultratb.py in structured_traceback(self, etype, value, tb, tb_offset, number_of_lines_of_context)
1365 else:
1366 self.tb = tb
-> 1367 return FormattedTB.structured_traceback(
1368 self, etype, value, tb, tb_offset, number_of_lines_of_context)
1369
/opt/conda/lib/python3.9/site-packages/IPython/core/ultratb.py in structured_traceback(self, etype, value, tb, tb_offset, number_of_lines_of_context)
1265 if mode in self.verbose_modes:
1266 # Verbose modes need a full traceback
-> 1267 return VerboseTB.structured_traceback(
1268 self, etype, value, tb, tb_offset, number_of_lines_of_context
1269 )
/opt/conda/lib/python3.9/site-packages/IPython/core/ultratb.py in structured_traceback(self, etype, evalue, etb, tb_offset, number_of_lines_of_context)
1122 """Return a nice text document describing the traceback."""
1123
-> 1124 formatted_exception = self.format_exception_as_a_whole(etype, evalue, etb, number_of_lines_of_context,
1125 tb_offset)
1126
/opt/conda/lib/python3.9/site-packages/IPython/core/ultratb.py in format_exception_as_a_whole(self, etype, evalue, etb, number_of_lines_of_context, tb_offset)
1080
1081
-> 1082 last_unique, recursion_repeat = find_recursion(orig_etype, evalue, records)
1083
1084 frames = self.format_records(records, last_unique, recursion_repeat)
/opt/conda/lib/python3.9/site-packages/IPython/core/ultratb.py in find_recursion(etype, value, records)
380 # first frame (from in to out) that looks different.
381 if not is_recursion_error(etype, value, records):
--> 382 return len(records), 0
383
384 # Select filename, lineno, func_name to track frames with
TypeError: object of type 'NoneType' has no len()
os._exit() worked but it does not print at what line the timeout happened
if I am not quitting the script it errors further, where the report is meant to be created (missing variable). I don't know what is wrong with this
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
