Skip to content

Update python eossdk_utils.py debug_fn to return function values#61

Open
jpsenior wants to merge 1 commit intoaristanetworks:masterfrom
jpsenior:patch-1
Open

Update python eossdk_utils.py debug_fn to return function values#61
jpsenior wants to merge 1 commit intoaristanetworks:masterfrom
jpsenior:patch-1

Conversation

@jpsenior
Copy link
Copy Markdown
Contributor

A @debug_fn wrapped function should also return the result of the function it executes, otherwise it returns None.

class SomeAgent(eossdk.IntfHandler):
    def __init__(self, sdk):
        self.intf_mgr = sdk.get_intf_mgr()
        self.tracer = eossdk.Tracer('debug_fn_sample')
        eossdk.IntfHandler.__init__(self, self.intf_mgr)

    @debug_fn
    def get_value(self):
        return 'foo'

    def on_oper_status(self, intf_id_t, oper_status_t):
        value = self.get_value()  # returns None.
        assert value == 'foo'

A @debug_fn wrapped function should also return the result of the function it executes, otherwise it returns None.

class SomeAgent(eossdk.IntfHandler):
    def __init__(self, sdk):
        self.intf_mgr = sdk.get_intf_mgr()
        self.tracer = eossdk.Tracer('debug_fn_sample')
        eossdk.IntfHandler.__init__(self, self.intf_mgr)

    @debug_fn
    def get_value(self):
        return 'foo'

    def on_oper_status(self, intf_id_t, oper_status_t):
        value = self.get_value()  # returns None.
        assert value == 'foo'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant