mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06: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.
|
# MA 02110-1301 USA.
|
||||||
#
|
#
|
||||||
|
|
||||||
from Queue import Queue, Empty
|
from Queue import Queue
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
@ -80,22 +80,12 @@ class vmmInspection(vmmGObject):
|
|||||||
self.timeout_add(self._wait, cb)
|
self.timeout_add(self._wait, cb)
|
||||||
|
|
||||||
def _run(self):
|
def _run(self):
|
||||||
while True:
|
|
||||||
self._process_queue()
|
|
||||||
|
|
||||||
# Process everything on the queue. If the queue is empty when
|
# Process everything on the queue. If the queue is empty when
|
||||||
# called, block.
|
# called, block.
|
||||||
def _process_queue(self):
|
|
||||||
first_obj = self._q.get()
|
|
||||||
self._process_queue_item(first_obj)
|
|
||||||
self._q.task_done()
|
|
||||||
try:
|
|
||||||
while True:
|
while True:
|
||||||
obj = self._q.get(False)
|
obj = self._q.get()
|
||||||
self._process_queue_item(obj)
|
self._process_queue_item(obj)
|
||||||
self._q.task_done()
|
self._q.task_done()
|
||||||
except Empty:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def _process_queue_item(self, obj):
|
def _process_queue_item(self, obj):
|
||||||
if obj[0] == "conn_added":
|
if obj[0] == "conn_added":
|
||||||
|
Loading…
Reference in New Issue
Block a user