#354 Stop loading whole pungi log into memory
Merged 4 years ago by lsedlar. Opened 4 years ago by lsedlar.
lsedlar/odcs remove-readlines  into  master

file modified
+1 -1
@@ -481,7 +481,7 @@ 

          try:

              with open(global_log_path, "r") as global_log:

                  error = ""

-                 for line in global_log.readlines():

+                 for line in global_log:

                      idx = line.find("[ERROR   ]")

                      if idx == -1:

                          if error:

The readlines method on file object reads the entire content as a list of lines. Since the list is iterated over only once, we can get the exact same outcome by iterating over the file object directly. That will also yield the lines one by one, but without waiting for the entire file to be read.

Pull-Request has been merged by lsedlar

4 years ago