mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-03 13:47:18 +03:00
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:
parent
7a696c8db8
commit
d2ca54fce4
@ -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":
|
||||
|
Loading…
x
Reference in New Issue
Block a user