0

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

Front end (browser)

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

Back end (python)

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

It gives a little bit of idea about the error. 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.

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
        ...

Is this the standard way to handle it?

Eddie
  • 1,043
  • 8
  • 14

1 Answers1

2

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
oberstet
  • 21,353
  • 10
  • 64
  • 97
  • Thank you, but unfortunately it doesn't seem to be working. When I include the above code, it doesn't call the onJoin function so can't yield the procedures. – Eddie Jan 19 '15 at 14:49
  • Quick fix, I just explicitly passed the self object as the first argument and it works. I mean instead of `ApplicationSession.__init__(config)` I called `ApplicationSession.__init__(self, config)`. Im glad it works like magic now. – Eddie Jan 19 '15 at 14:54
  • Oh, good catch. Yes, need to provide `self` when calling the base class constructor. I corrected the answer. Sorry. – oberstet Jan 19 '15 at 18:51