test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH] Optimize rescan_ports function with read cache option
@ 2015-07-13  5:46 Yong Liu
  0 siblings, 0 replies; only message in thread
From: Yong Liu @ 2015-07-13  5:46 UTC (permalink / raw)
  To: dts

From: Marvin Liu <yong.liu@intel.com>

When read_cache enabled, skip rescan ports when there's available port infor.
Only update cache file and PORT_INFO_CACHE_KEY after rescan ports function.

Signed-off-by: Marvin Liu <yong.liu@intel.com>

diff --git a/framework/dut.py b/framework/dut.py
index aaaaf36..bbc6274 100644
--- a/framework/dut.py
+++ b/framework/dut.py
@@ -513,6 +513,17 @@ class Dut(Crb):
         return False
 
     def rescan_ports(self):
+        """
+        Rescan ports information
+        """
+        if self.read_cache and self.load_serializer_ports():
+            return
+
+        if self.ports_info:
+            self.rescan_ports_uncached()
+            self.save_serializer_ports()
+
+    def rescan_ports_uncached(self):
         unknow_interface = RED('Skipped: unknow_interface')
 
         for port_info in self.ports_info:
@@ -540,7 +551,7 @@ class Dut(Crb):
     def load_serializer_ports(self):
         cached_ports_info = self.serializer.load(self.PORT_INFO_CACHE_KEY)
         if cached_ports_info is None:
-            return
+            return None
 
         self.ports_info = cached_ports_info
 
@@ -564,7 +575,6 @@ class Dut(Crb):
 
         if not self.read_cache or self.ports_info is None:
             self.scan_ports_uncached()
-            self.save_serializer_ports()
 
     def scan_ports_cached(self):
         """
-- 
1.9.3

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-07-13  5:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-13  5:46 [dts] [PATCH] Optimize rescan_ports function with read cache option Yong Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).