py-electrolux-ocp icon indicating copy to clipboard operation
py-electrolux-ocp copied to clipboard

Blocking await

Open albaintor opened this issue 1 year ago • 3 comments

Hi,

since this update, the call to "watch_for_appliance_state_updates" blocks and won't return. So the component initialization is blocked. Before the method would return immediately and the callback would be called at each message received image

Thanks for your support

albaintor avatar Feb 15 '24 11:02 albaintor

Is this a problem? I can change it back. You can always start this as a background task on client side. using asyncio.create_task(watch_for_appliance_state_updates()) instead of calling it directly

But there might be scenarios where websocket listening fails and you would want be informed when watch_for_appliance_state_updates fails or stops. Then you can call it again, or do some more actions before retrying

Woyken avatar Feb 15 '24 12:02 Woyken

This is exactly what I wonder : I am facing the same question on another integration. For electrolux we only want to receive messages on my other integration if I want to send messages I need to know when the websocket connection is initialized before sending any message.

albaintor avatar Feb 15 '24 12:02 albaintor

I'll try to create a separate task as hinted thanks

albaintor avatar Feb 15 '24 12:02 albaintor