Python-asyncio, Wamp client, onDisconnect does not execture after I override method leave of the session

#1

Hi

I just started using Autobahn wamp client, and I am trying to execute an asyncio coroutine on leave. This is the code:

class MyWebsocketClient(ApplicationSession):
#do stuff

def leave(self, reason=None, log_message=None):
result = super().leave(reason=reason, log_message=log_message)

return self.event_loop.create_task(self.ask_leave(result))

async def ask_leave(self, result):
#do leaving asyncio stuff

return result

When I run this code everything seems to run fine, except that onDisconnect does not get triggered like it does if I do not override the leave method. So I would like to know what am I doing wrong or what is the best way of running an asyncio coroutine when the client is leaving.

Thanks,

0 Likes

#2

Hi

I just started using Autobahn wamp client, and I am trying to execute an
asyncio coroutine on leave. This is the code:

class MyWebsocketClient(ApplicationSession):
  #do stuff

  def leave(self, reason=None, log_message=None):
    result = super().leave(reason=reason, log_message=log_message)

    return self.event_loop.create_task(self.ask_leave(result))

  async def ask_leave(self, result):
    #do leaving asyncio stuff

    return result

When I run this code everything seems to run fine, except that onDisconnect
does not get triggered like it does if I do not override the leave method.
So I would like to know what am I doing wrong or what is the best way of
running an asyncio coroutine when the client is leaving.

override onLeave() ..

http://autobahn.readthedocs.io/en/latest/wamp/programming.html#session-lifecycle

the default impl. of onLeave() will disconnect:

https://github.com/crossbario/autobahn-python/blob/master/autobahn/wamp/protocol.py#L1093

···

Am 15.03.2017 um 17:25 schrieb george....@gmail.com:

Thanks,

0 Likes