Skip to content

Commit 22e6933

Browse files
committed
Add sleep to allow other tasks
1 parent eccf56d commit 22e6933

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

plugwise_usb/connection/queue.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Manage the communication sessions towards the USB-Stick."""
22
from __future__ import annotations
33

4-
from asyncio import PriorityQueue, Task, get_running_loop
4+
from asyncio import PriorityQueue, Task, get_running_loop, sleep
55
from collections.abc import Callable
66
from dataclasses import dataclass
77
import logging
@@ -97,7 +97,7 @@ async def submit(
9797
if isinstance(request, NodePingRequest):
9898
# For ping requests it is expected to receive timeouts, so lower log level
9999
_LOGGER.debug("%s, cancel because timeout is expected for NodePingRequests", e)
100-
if request.resend:
100+
elif request.resend:
101101
_LOGGER.info("%s, retrying", e)
102102
else:
103103
_LOGGER.warning("%s, cancel request", e) # type: ignore[unreachable]
@@ -142,5 +142,6 @@ async def _send_queue_worker(self) -> None:
142142
return
143143
await self._stick.write_to_stick(request)
144144
self._submit_queue.task_done()
145+
await sleep(0.001)
145146
_LOGGER.debug("Sent from queue %s", request)
146147
_LOGGER.debug("Send_queue_worker stopped")

0 commit comments

Comments
 (0)