@@ -214,76 +214,42 @@ def setup_once() -> None:
214214 )
215215 return
216216
217- pre_37 = hasattr (lambda_bootstrap , "handle_http_request" ) # Python 3.6
217+ lambda_bootstrap .LambdaRuntimeClient .post_init_error = _wrap_init_error (
218+ lambda_bootstrap .LambdaRuntimeClient .post_init_error
219+ )
218220
219- if pre_37 :
220- old_handle_event_request = lambda_bootstrap .handle_event_request
221+ old_handle_event_request = lambda_bootstrap .handle_event_request
221222
222- def sentry_handle_event_request (
223- request_handler : "Any" , * args : "Any" , ** kwargs : "Any"
224- ) -> "Any" :
225- request_handler = _wrap_handler (request_handler )
226- return old_handle_event_request (request_handler , * args , ** kwargs )
227-
228- lambda_bootstrap .handle_event_request = sentry_handle_event_request
229-
230- old_handle_http_request = lambda_bootstrap .handle_http_request
231-
232- def sentry_handle_http_request (
233- request_handler : "Any" , * args : "Any" , ** kwargs : "Any"
234- ) -> "Any" :
235- request_handler = _wrap_handler (request_handler )
236- return old_handle_http_request (request_handler , * args , ** kwargs )
237-
238- lambda_bootstrap .handle_http_request = sentry_handle_http_request
239-
240- # Patch to_json to drain the queue. This should work even when the
241- # SDK is initialized inside of the handler
242-
243- old_to_json = lambda_bootstrap .to_json
244-
245- def sentry_to_json (* args : "Any" , ** kwargs : "Any" ) -> "Any" :
246- _drain_queue ()
247- return old_to_json (* args , ** kwargs )
248-
249- lambda_bootstrap .to_json = sentry_to_json
250- else :
251- lambda_bootstrap .LambdaRuntimeClient .post_init_error = _wrap_init_error (
252- lambda_bootstrap .LambdaRuntimeClient .post_init_error
253- )
254-
255- old_handle_event_request = lambda_bootstrap .handle_event_request
256-
257- def sentry_handle_event_request ( # type: ignore
223+ def sentry_handle_event_request ( # type: ignore
224+ lambda_runtime_client , request_handler , * args , ** kwargs
225+ ):
226+ request_handler = _wrap_handler (request_handler )
227+ return old_handle_event_request (
258228 lambda_runtime_client , request_handler , * args , ** kwargs
259- ):
260- request_handler = _wrap_handler (request_handler )
261- return old_handle_event_request (
262- lambda_runtime_client , request_handler , * args , ** kwargs
263- )
229+ )
264230
265- lambda_bootstrap .handle_event_request = sentry_handle_event_request
231+ lambda_bootstrap .handle_event_request = sentry_handle_event_request
266232
267- # Patch the runtime client to drain the queue. This should work
268- # even when the SDK is initialized inside of the handler
233+ # Patch the runtime client to drain the queue. This should work
234+ # even when the SDK is initialized inside of the handler
269235
270- def _wrap_post_function (f : "F" ) -> "F" :
271- def inner (* args : "Any" , ** kwargs : "Any" ) -> "Any" :
272- _drain_queue ()
273- return f (* args , ** kwargs )
236+ def _wrap_post_function (f : "F" ) -> "F" :
237+ def inner (* args : "Any" , ** kwargs : "Any" ) -> "Any" :
238+ _drain_queue ()
239+ return f (* args , ** kwargs )
274240
275- return inner # type: ignore
241+ return inner # type: ignore
276242
277- lambda_bootstrap .LambdaRuntimeClient .post_invocation_result = (
278- _wrap_post_function (
279- lambda_bootstrap .LambdaRuntimeClient .post_invocation_result
280- )
243+ lambda_bootstrap .LambdaRuntimeClient .post_invocation_result = (
244+ _wrap_post_function (
245+ lambda_bootstrap .LambdaRuntimeClient .post_invocation_result
281246 )
282- lambda_bootstrap . LambdaRuntimeClient . post_invocation_error = (
283- _wrap_post_function (
284- lambda_bootstrap . LambdaRuntimeClient . post_invocation_error
285- )
247+ )
248+ lambda_bootstrap . LambdaRuntimeClient . post_invocation_error = (
249+ _wrap_post_function (
250+ lambda_bootstrap . LambdaRuntimeClient . post_invocation_error
286251 )
252+ )
287253
288254
289255def get_lambda_bootstrap () -> "Optional[Any]" :
0 commit comments