From e9695581ef33f7d3b12bdbe305778920e62f6319 Mon Sep 17 00:00:00 2001 From: Divyank Jain Date: Mon, 26 Aug 2024 09:54:55 -0400 Subject: [PATCH] Truncate traceback beyond 200kb --- temporalio/worker/_workflow.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/temporalio/worker/_workflow.py b/temporalio/worker/_workflow.py index dd521fdd..079c7752 100644 --- a/temporalio/worker/_workflow.py +++ b/temporalio/worker/_workflow.py @@ -502,8 +502,14 @@ def _gen_tb_helper( thread_frames.reverse() + size = 0 tb = None for frm in thread_frames: tb = TracebackType(tb, frm, frm.f_lasti, frm.f_lineno) + size += sys.getsizeof(tb) + + while size > 200000 and tb: + size -= sys.getsizeof(tb) + tb = tb.tb_next return tb