driver: Close incoming awaitable fn if queue is full
This commit is contained in:
parent
76a19cb65a
commit
753a16ab8e
@ -742,11 +742,12 @@ class Kirdy:
|
|||||||
Enqueue a task to be handled by the handler.
|
Enqueue a task to be handled by the handler.
|
||||||
"""
|
"""
|
||||||
if self.connected():
|
if self.connected():
|
||||||
try:
|
if self._task_queue.full():
|
||||||
|
awaitable_fn.close()
|
||||||
|
return False
|
||||||
|
else:
|
||||||
self._task_queue.put_nowait(lambda: awaitable_fn)
|
self._task_queue.put_nowait(lambda: awaitable_fn)
|
||||||
return True
|
return True
|
||||||
except asyncio.queues.QueueFull:
|
|
||||||
return False
|
|
||||||
else:
|
else:
|
||||||
raise ConnectionError
|
raise ConnectionError
|
||||||
|
|
||||||
@ -861,7 +862,8 @@ class Kirdy:
|
|||||||
async def __coninit(self, timeout):
|
async def __coninit(self, timeout):
|
||||||
def _put_nowait_overwrite(self, item):
|
def _put_nowait_overwrite(self, item):
|
||||||
if self.full():
|
if self.full():
|
||||||
self.get_nowait()
|
awaitable_fn = self.get_nowait()
|
||||||
|
awaitable_fn.close()
|
||||||
self.put_nowait(item)
|
self.put_nowait(item)
|
||||||
asyncio.Queue.put_nowait_overwrite = _put_nowait_overwrite
|
asyncio.Queue.put_nowait_overwrite = _put_nowait_overwrite
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user