Woyken / py-electrolux-ocp

Electrolux OCP api using electrolux OneApp (pyelectroluxocp) https://api.ocp.electrolux.one
https://pypi.org/project/pyelectroluxocp/
MIT License
26 stars 2 forks source link

Blocking await #8

Open albaintor opened 7 months ago

albaintor commented 7 months ago

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

Woyken commented 7 months ago

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

albaintor commented 7 months ago

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 commented 7 months ago

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