File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ class DroppingPriorityQueue(Queue):
3636
3737 def _init (self , maxsize ):
3838 # called by asyncio.Queue.__init__
39+ self .dropped_msgs = 0
3940 self ._queue = SortedList ()
4041
4142 def _put (self , item ):
@@ -50,6 +51,7 @@ def _get(self):
5051 def __drop (self ):
5152 # drop the last (least important) item from the queue
5253 self ._queue .pop ()
54+ self .dropped_msgs += 1
5355 # no consumer will get a chance to process this item, so
5456 # we must decrement the unfinished count ourselves
5557 self .task_done ()
@@ -191,9 +193,10 @@ async def _send_queue_worker(self) -> None:
191193 self ._submit_queue .task_done ()
192194 return
193195
194- if self ._stick .queue_depth > 3 :
196+ queue_depth = self ._stick .queue_depth - self ._submit_queue .dropped_msgs
197+ if queue_depth > 3 :
195198 _LOGGER .warning (
196- "Awaiting plugwise responses %d" , self . _stick . queue_depth
199+ "Awaiting plugwise responses %d" , queue_depth
197200 )
198201 await sleep (0.125 )
199202
You can’t perform that action at this time.
0 commit comments