使用SUDS Python WSDL客户端和Django Sentry,使用__sentry__属性进行异常

时间:2011-09-15 08:58:14

标签: python django suds sentry

在Django应用程序中使用SUDS时,除了Sentry错误记录外,我遇到了一个问题,即SUDS引发错误,Sentry试图处理它,失败并导致服务器500:

[Wed Sep 14 16:06:22 2011] [error] Unable to process log entry: plugin domain (__sentry__), invalid
[Wed Sep 14 16:06:22 2011] [error] Traceback (most recent call last):
[Wed Sep 14 16:06:22 2011] [error]   File "/opt/envs/xxxx/lib/python2.6/site-packages/sentry/client/models.py", line 38, in sentry_exception_handler
[Wed Sep 14 16:06:22 2011] [error]     message_id = get_client().create_from_exception(**extra)
[Wed Sep 14 16:06:22 2011] [error]   File "/opt/envs/xxxx/lib/python2.6/site-packages/sentry/client/base.py", line 220, in create_from_exception
[Wed Sep 14 16:06:22 2011] [error]     frames = varmap(shorten, reporter.get_traceback_frames())
[Wed Sep 14 16:06:22 2011] [error]   File "/opt/envs/xxxx/lib/python2.6/site-packages/sentry/helpers.py", line 68, in varmap
[Wed Sep 14 16:06:22 2011] [error]     ret = [varmap(func, f, context) for f in var]
[Wed Sep 14 16:06:22 2011] [error]   File "/opt/envs/xxxx/lib/python2.6/site-packages/sentry/helpers.py", line 66, in varmap
[Wed Sep 14 16:06:22 2011] [error]     ret = dict((k, varmap(func, v, context)) for k, v in var.iteritems())
[Wed Sep 14 16:06:22 2011] [error]   File "/opt/envs/xxxx/lib/python2.6/site-packages/sentry/helpers.py", line 66, in <genexpr>
[Wed Sep 14 16:06:22 2011] [error]     ret = dict((k, varmap(func, v, context)) for k, v in var.iteritems())
[Wed Sep 14 16:06:22 2011] [error]   File "/opt/envs/xxxx/lib/python2.6/site-packages/sentry/helpers.py", line 68, in varmap
[Wed Sep 14 16:06:22 2011] [error]     ret = [varmap(func, f, context) for f in var]
[Wed Sep 14 16:06:22 2011] [error]   File "/opt/envs/xxxx/lib/python2.6/site-packages/sentry/helpers.py", line 68, in varmap
[Wed Sep 14 16:06:22 2011] [error]     ret = [varmap(func, f, context) for f in var]
[Wed Sep 14 16:06:22 2011] [error]   File "/opt/envs/xxxx/lib/python2.6/site-packages/sentry/helpers.py", line 70, in varmap
[Wed Sep 14 16:06:22 2011] [error]     ret = func(var)
[Wed Sep 14 16:06:22 2011] [error]   File "/opt/envs/xxxx/lib/python2.6/site-packages/sentry/helpers.py", line 235, in shorten
[Wed Sep 14 16:06:22 2011] [error]     var = transform(var)
[Wed Sep 14 16:06:22 2011] [error]   File "/opt/envs/xxxx/lib/python2.6/site-packages/sentry/helpers.py", line 101, in transform
[Wed Sep 14 16:06:22 2011] [error]     callable(getattr(value, '__sentry__', None)):
[Wed Sep 14 16:06:22 2011] [error]   File "/opt/envs/xxxx/lib/python2.6/site-packages/suds/plugin.py", line 208, in __getattr__
[Wed Sep 14 16:06:22 2011] [error]     raise Exception, 'plugin domain (%s), invalid' % name
[Wed Sep 14 16:06:22 2011] [error] Exception: plugin domain (__sentry__), invalid

像Sentry和SUDS似乎打得不好......?

1 个答案:

答案 0 :(得分:3)

看起来SUDS实际上在其插件文件中抛出了错误的错误类型,因此Sentry无法处理它(Sentry尝试在引发异常的对象上调用__sentry__,我猜AttributeError将被退回.SUDS只会引发(旧式)异常......

请参阅:https://fedorahosted.org/suds/browser/trunk/suds/plugin.py#L208

也许修补它来引发一个AttributeError ......但这可能不是最好的解决方案......还有其他吗?