@@ -1501,6 +1501,20 @@ def stop(self):
15011501 # type: () -> None
15021502 self ._stop_event .set ()
15031503
1504+ def _capture_exception (self ):
1505+ # type: () -> ExcInfo
1506+ exc_info = sys .exc_info ()
1507+
1508+ client = sentry_sdk .get_client ()
1509+ event , hint = event_from_exception (
1510+ exc_info ,
1511+ client_options = client .options ,
1512+ mechanism = {"type" : "threading" , "handled" : False },
1513+ )
1514+ sentry_sdk .capture_event (event , hint = hint )
1515+
1516+ return exc_info
1517+
15041518 def run (self ):
15051519 # type: () -> None
15061520
@@ -1515,18 +1529,19 @@ def run(self):
15151529 if integer_configured_timeout < self .configured_timeout :
15161530 integer_configured_timeout = integer_configured_timeout + 1
15171531
1518- from sentry_sdk .scope import use_isolation_scope , use_scope
1519-
15201532 if self .isolation_scope is not None and self .current_scope is not None :
1521- with use_isolation_scope (self .isolation_scope ):
1522- with use_scope (self .current_scope ):
1523- # with use_scope(self.current_scope):
1524- # Raising Exception after timeout duration is reached
1525- raise ServerlessTimeoutWarning (
1526- "WARNING : Function is expected to get timed out. Configured timeout duration = {} seconds." .format (
1527- integer_configured_timeout
1533+ with sentry_sdk .scope .use_isolation_scope (self .isolation_scope ):
1534+ with sentry_sdk .scope .use_scope (self .current_scope ):
1535+ try :
1536+ # with use_scope(self.current_scope):
1537+ # Raising Exception after timeout duration is reached
1538+ raise ServerlessTimeoutWarning (
1539+ "WARNING : Function is expected to get timed out. Configured timeout duration = {} seconds." .format (
1540+ integer_configured_timeout
1541+ )
15281542 )
1529- )
1543+ except Exception :
1544+ reraise (* self ._capture_exception ())
15301545
15311546
15321547def to_base64 (original ):
0 commit comments