Why can't I define a connection_lost_callback this way? #2017
Unanswered
iamthebull
asked this question in
Q&A
Replies: 1 comment
|
This happens because self.connection_lost_callback = NoneThat instance attribute shadows your subclass method named Use assignment after from asyncua import Client
class MyClient(Client):
def __init__(self, url):
super().__init__(url)
self.connection_lost_callback = self._on_connection_lost
async def _on_connection_lost(self, exc):
print("connection lost:", exc)Two details matter:
If this fixes your handler, please mark the answer so others do not run into the subclass-shadowing trap. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
In my app I subclass
asyncua.Clientand I am trying to add aconnection_lost_callbackas follows. When I do it this way thenclient.connection_lost_callbackis alwaysNoneand thus is never called.but this does
I don't understand why in the first case the
connection_lost_callbackmethods are being overwritten to None.All reactions