homeassistant-elasticsearch icon indicating copy to clipboard operation
homeassistant-elasticsearch copied to clipboard

[2.0] Use of sync queue implementation and blocking queue calls

Open strawgate opened this issue 10 months ago • 1 comments

The Queue implementation we use is not async safe and so we should switch to asyncio.queue instead of queue to avoid blocking. The queue implementations are highly compatible with the only change being adding await before commands that change the queue.

In addition, the various queue commands we use, get and put technically block in certain situations. put blocks if there is no more capacity in the queue (we currently use an unlimited capacity queue) and get blocks if there are no more items in the queue. We only call get when the queue is not empty so this shouldn't be a problem but switching to non-blocking get is probably the safer move.

strawgate avatar Jan 14 '25 14:01 strawgate

Thanks for raising this - I'm in favor of this change

legrego avatar Jan 14 '25 16:01 legrego