File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,9 @@ def create_troubleshootting_log_message(
3131 def _collect_causes (exc : BaseException ) -> str :
3232 causes = []
3333 current = exc .__cause__
34- while current is not None :
34+ seen = set () # Prevent infinite loops
35+ while current is not None and id (current ) not in seen :
36+ seen .add (id (current ))
3537 causes .append (f"[{ type (current ).__name__ } ]'{ current } '" )
3638 current = getattr (current , "__cause__" , None )
3739 return " <- " .join (causes )
Original file line number Diff line number Diff line change @@ -207,12 +207,16 @@ async def _func() -> None:
207207 assert mock_func .call_count > 1
208208
209209
210+ class CustomError (Exception ):
211+ pass
212+
213+
210214async def test_periodic_task_logs_error (
211215 mock_background_task : mock .AsyncMock ,
212216 task_interval : datetime .timedelta ,
213217 caplog : pytest .LogCaptureFixture ,
214218):
215- mock_background_task .side_effect = RuntimeError ("Test error" )
219+ mock_background_task .side_effect = CustomError ("Test error" )
216220
217221 with caplog .at_level (logging .ERROR ):
218222 async with periodic_task (
You can’t perform that action at this time.
0 commit comments