记录WAMP worker追溯错误 [英] Logging WAMP worker Trace Back Error

查看:75
本文介绍了记录WAMP worker追溯错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试调试基于WAMP(Web应用程序消息协议)的python组件的远程过程调用。例如:

I have been trying to debug Remote Procedure Calls for WAMP (Web Application Messaging Protocol) based python components. For example:

前端(浏览器)

session.call('math.add2', [2, 'two']);

后端(python)

@wamp.register("math.add2")
def add2(self, x, y):
    return x + y

它给出了一些有关错误的想法。

It gives a little bit of idea about the error.

例如像这样,这根本不重要,但是对于具有大量文件和模块的大型应用程序,我不太清楚找出错误的最佳方法,以便它输出带有文件名,行号的完整错误跟踪和说明。

For a simple example like this, it doesn't really matter at all but for large applications with a lot of files and modules, Im not quite sure about the best way to pin point the errors so that it outputs the full error trace with file name, line number and description.

作为解决方案,我对 wamp.py 进行了一些修改(添加了 traceback.print_exc()),如下所示以在控制台日志上输出错误:

As a solution, I have slightly modified the wamp.py (added the line traceback.print_exc()) like below to output the errors on the console log:

# autobahn/asyncio/wamp.py
...
import traceback
...

class FutureMixin:
  ...
  @staticmethod
  def _as_future(fun, *args, **kwargs):
     try:
        res = fun(*args, **kwargs)
     except Exception as e:
        traceback.print_exc() # Added this line
        ...

这是

推荐答案

AutobahnPython允许您打开WAMP错误消息中的回溯发送功能:

AutobahnPython allows you to turn on sending tracebacks in WAMP error messages:

class MyComponent(ApplicationSession):
   def __init__(self, config = None):
      ApplicationSession.__init__(self, config)
      self.traceback_app = True

这篇关于记录WAMP worker追溯错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆