inspection: remove queue draining

Now we act for each item in the queue, so there is no more need to drain
it fully before doing anything.  Thus, turn _run into a simple
get+process+done loop.
This commit is contained in:
Pino Toscano 2017-02-23 11:22:23 +01:00 committed by Cole Robinson
parent 7a696c8db8
commit d2ca54fce4

View File

@ -17,7 +17,7 @@
# MA 02110-1301 USA.
#
from Queue import Queue, Empty
from Queue import Queue
from threading import Thread
import logging
import re
@ -80,22 +80,12 @@ class vmmInspection(vmmGObject):
self.timeout_add(self._wait, cb)
def _run(self):
# Process everything on the queue. If the queue is empty when
# called, block.
while True:
self._process_queue()
# Process everything on the queue. If the queue is empty when
# called, block.
def _process_queue(self):
first_obj = self._q.get()
self._process_queue_item(first_obj)
self._q.task_done()
try:
while True:
obj = self._q.get(False)
self._process_queue_item(obj)
self._q.task_done()
except Empty:
pass
obj = self._q.get()
self._process_queue_item(obj)
self._q.task_done()
def _process_queue_item(self, obj):
if obj[0] == "conn_added":