@@ -1484,11 +1484,17 @@ class TimeoutThread(threading.Thread):
14841484 waiting_time and raises a custom ServerlessTimeout exception.
14851485 """
14861486
1487- def __init__ (self , waiting_time , configured_timeout ):
1488- # type: (float, int) -> None
1487+ def __init__ (
1488+ self , waiting_time , configured_timeout , isolation_scope = None , current_scope = None
1489+ ):
1490+ # type: (float, int, Optional[Scope], Optional[Scope]) -> None
14891491 threading .Thread .__init__ (self )
14901492 self .waiting_time = waiting_time
14911493 self .configured_timeout = configured_timeout
1494+
1495+ self .isolation_scope = isolation_scope
1496+ self .current_scope = current_scope
1497+
14921498 self ._stop_event = threading .Event ()
14931499
14941500 def stop (self ):
@@ -1509,12 +1515,17 @@ def run(self):
15091515 if integer_configured_timeout < self .configured_timeout :
15101516 integer_configured_timeout = integer_configured_timeout + 1
15111517
1512- # Raising Exception after timeout duration is reached
1513- raise ServerlessTimeoutWarning (
1514- "WARNING : Function is expected to get timed out. Configured timeout duration = {} seconds." .format (
1515- integer_configured_timeout
1516- )
1517- )
1518+ from sentry_sdk .scope import use_isolation_scope , use_scope
1519+
1520+ with use_isolation_scope (self .isolation_scope ):
1521+ with use_scope (self .current_scope ):
1522+ # with use_scope(self.current_scope):
1523+ # Raising Exception after timeout duration is reached
1524+ raise ServerlessTimeoutWarning (
1525+ "WARNING : Function is expected to get timed out. Configured timeout duration = {} seconds." .format (
1526+ integer_configured_timeout
1527+ )
1528+ )
15181529
15191530
15201531def to_base64 (original ):
0 commit comments