mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-25 23:21:45 +03:00
addstorage: Rate limit the default pool refresh
This commit is contained in:
parent
76bc8e5ab9
commit
3753fcbaa3
@ -20,6 +20,7 @@
|
||||
import logging
|
||||
import os
|
||||
import statvfs
|
||||
import time
|
||||
|
||||
from gi.repository import GObject
|
||||
from gi.repository import Gtk
|
||||
@ -78,9 +79,9 @@ class vmmAddStorage(vmmGObjectUI):
|
||||
|
||||
avail = 0
|
||||
if pool and pool.is_active():
|
||||
# FIXME: make sure not inactive?
|
||||
# FIXME: use a conn specific function after we send pool-added
|
||||
pool.refresh()
|
||||
# Rate limit this, since it can be spammed at dialog startup time
|
||||
if ((time.time() - pool.get_last_refresh_time()) > 10):
|
||||
pool.refresh()
|
||||
avail = int(pool.get_available())
|
||||
|
||||
elif not self.conn.is_remote() and os.path.exists(path):
|
||||
|
@ -19,6 +19,7 @@
|
||||
#
|
||||
|
||||
import logging
|
||||
import time
|
||||
|
||||
from gi.repository import GObject
|
||||
|
||||
@ -104,6 +105,7 @@ class vmmStoragePool(vmmLibvirtObject):
|
||||
|
||||
self._active = True
|
||||
self._support_isactive = None
|
||||
self._last_refresh_time = 0
|
||||
|
||||
self._volumes = {}
|
||||
|
||||
@ -182,6 +184,10 @@ class vmmStoragePool(vmmLibvirtObject):
|
||||
self.refresh_xml()
|
||||
self._update_volumes()
|
||||
self.idle_emit("refreshed")
|
||||
self._last_refresh_time = time.time()
|
||||
|
||||
def get_last_refresh_time(self):
|
||||
return self._last_refresh_time
|
||||
|
||||
def define_name(self, newname):
|
||||
return self._define_name_helper("storagepool",
|
||||
|
Loading…
Reference in New Issue
Block a user