hvoss-techfak commited on
Commit
8513b12
·
1 Parent(s): 54810a9

fix monkey patch

Browse files
Files changed (1) hide show
  1. app.py +11 -12
app.py CHANGED
@@ -36,20 +36,19 @@ sentry_sdk.capture_message("🎉 Sentry is wired up!")
36
  import gradio, functools
37
  from sentry_sdk import capture_exception, flush
38
 
39
- orig_run_sync = gradio.utils.run_sync # Gradio 4.x helper
40
 
41
- def sentry_run_sync(fn):
42
- @functools.wraps(fn)
43
- def _wrapped(*args, **kwargs):
44
- try:
45
- return fn(*args, **kwargs)
46
- except Exception as exc:
47
- capture_exception(exc)
48
- flush(timeout=2)
49
- raise
50
- return _wrapped
51
 
52
- gradio.utils.run_sync = sentry_run_sync # global patch
53
 
54
 
55
  import gradio as gr
 
36
  import gradio, functools
37
  from sentry_sdk import capture_exception, flush
38
 
39
+ orig_call_fn = gradio.blocks.Blocks.call_function # present in all 3.x & 4.x
40
 
41
+ @functools.wraps(orig_call_fn)
42
+ async def sentry_call_fn(self, *args, **kwargs):
43
+ try:
44
+ return await orig_call_fn(self, *args, **kwargs)
45
+ except Exception as exc:
46
+ capture_exception(exc)
47
+ flush(timeout=2)
48
+ raise
49
+
50
+ gradio.blocks.Blocks.call_function = sentry_call_fn
51
 
 
52
 
53
 
54
  import gradio as gr