Closed lkaupp closed 2 months ago
I also used the method self._client.get_node(), which is the same as my method implementation basically. However, still no events. What was altered during refactoring / rewriting the library to asyncio in the subscription process? Any ideas to debug the issue?
Whats the code after your posted code? If you leave the with Statement the client will disconnect.
Well here. Keep_running is true the whole time (same code as with freeopcua, which is working fine).:
while self._keep_running:
pass
print("unsubscribe")
await self._opcua_subscription.unsubscribe(self._opcua_handle)
time.sleep(10)
await self._opcua_subscription.delete()
Maybe next week I get the chance to capture a debug log. Which information do you need, and what commands should I use to get the necessary information?
I think you need to give the asyncio some timeslot, also you are wasting cpu cycles. Try this:
while self._keep_running:
await asyncio.sleep(1.0)
Thanks for the tip. I will try your snippet as soon as I can enter the factory again.
await asyncio.sleep(1.0)
you are officially my hero, never expected that a while pass loop prevents messages from being delivered. Is this asyncio related - do I prevent any internal loops?
In asyncio you block the async loop until you call the next await. If you need to run code that doesn't call await for a while, there some solutions, like asyncio.to_thread for I/O bound or run_in_executor for cpu bound tasks.
Thanks for the explanation. I close my issue and reference your answer in the discussion!
Discussed in https://github.com/FreeOpcUa/opcua-asyncio/discussions/1617