clear all the queues on exit.

This commit is contained in:
Matthew Stratford 2021-09-24 21:12:38 +01:00
parent bc1bd45cd4
commit d6751dc41f

View file

@ -329,6 +329,28 @@ class BAPSicleServer:
del self.player del self.player
print("Deleting all queues.")
# Should speed up GC on exit a bit.
queues = [
self.player_to_q,
self.player_from_q,
self.ui_to_q,
self.websocket_to_q,
self.controller_to_q,
self.file_to_q,
]
for queue in queues:
if isinstance(queue, List):
for inner_queue in queue:
while not inner_queue.empty():
inner_queue.get()
del inner_queue
elif isinstance(queue, Queue):
while not queue.empty():
queue.get()
for queue in queues:
del queue
print("Stopped all processes.") print("Stopped all processes.")