File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 22
33from __future__ import annotations
44
5- from asyncio import PriorityQueue , Task , get_running_loop , sleep
5+ from asyncio import (
6+ PriorityQueue ,
7+ Task ,
8+ TimeoutError ,
9+ get_running_loop ,
10+ sleep ,
11+ wait_for ,
12+ )
613from collections .abc import Callable
714from dataclasses import dataclass
815import logging
@@ -138,7 +145,11 @@ async def _send_queue_worker(self) -> None:
138145 """Send messages from queue at the order of priority."""
139146 _LOGGER .debug ("Send_queue_worker started" )
140147 while self ._running and self ._stick is not None :
141- request = await self ._submit_queue .get ()
148+ try :
149+ request = await wait_for (self ._submit_queue .get (), timeout = 0.5 )
150+ except TimeoutError :
151+ _LOGGER .debug ("No queue-item after 0.5s, doing other work" )
152+
142153 _LOGGER .debug ("Sending from send queue %s" , request )
143154 if request .priority == Priority .CANCEL :
144155 self ._submit_queue .task_done ()
You can’t perform that action at this time.
0 commit comments