handle full queue better by draining
This commit is contained in:
parent
c947204356
commit
e10a52b39e
@ -12,7 +12,7 @@ from owrx.bookmarks import Bookmarks
|
|||||||
from owrx.map import Map
|
from owrx.map import Map
|
||||||
from owrx.property import PropertyStack
|
from owrx.property import PropertyStack
|
||||||
from owrx.modes import Modes, DigitalMode
|
from owrx.modes import Modes, DigitalMode
|
||||||
from queue import Queue, Full
|
from queue import Queue, Full, Empty
|
||||||
from js8py import Js8Frame
|
from js8py import Js8Frame
|
||||||
from abc import ABC, ABCMeta, abstractmethod
|
from abc import ABC, ABCMeta, abstractmethod
|
||||||
import json
|
import json
|
||||||
@ -58,7 +58,16 @@ class Client(ABC):
|
|||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
if self.multithreadingQueue is not None:
|
if self.multithreadingQueue is not None:
|
||||||
self.multithreadingQueue.put(PoisonPill)
|
while True:
|
||||||
|
try:
|
||||||
|
self.multithreadingQueue.get(block=False)
|
||||||
|
except Empty:
|
||||||
|
break
|
||||||
|
try:
|
||||||
|
self.multithreadingQueue.put(PoisonPill, block=False)
|
||||||
|
except Full:
|
||||||
|
# this shouldn't happen, we just emptied the queue, but it's not worth risking the exception
|
||||||
|
logger.exception("impossible queue state: Full after Empty")
|
||||||
self.conn.close()
|
self.conn.close()
|
||||||
|
|
||||||
def mp_send(self, data):
|
def mp_send(self, data):
|
||||||
|
Loading…
Reference in New Issue
Block a user