guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

04/07: Handle eof when reading logs


From: Christopher Baines
Subject: 04/07: Handle eof when reading logs
Date: Thu, 9 Nov 2023 11:45:02 -0500 (EST)

cbaines pushed a commit to branch master
in repository data-service.

commit 341eb4a2838ff1d39601f22badcb99a19acbab0c
Author: Christopher Baines <mail@cbaines.net>
AuthorDate: Sun Nov 5 18:49:11 2023 +0000

    Handle eof when reading logs
---
 guix-data-service/jobs.scm | 43 +++++++++++++++++++++++--------------------
 1 file changed, 23 insertions(+), 20 deletions(-)

diff --git a/guix-data-service/jobs.scm b/guix-data-service/jobs.scm
index 9bac5e1..f848f2e 100644
--- a/guix-data-service/jobs.scm
+++ b/guix-data-service/jobs.scm
@@ -72,33 +72,36 @@ VALUES (nextval('" (log-part-sequence-name job_id) "'), $1, 
$2)")
             (list job-id))
 
            (let loop ((line (get-line port-to-read-from)))
-             (let ((line-with-newline
-                    (string-append line "\n")))
-               (catch #t
-                 (lambda ()
-                   (insert logging-conn job-id line-with-newline)
-                   (display line-with-newline))
-                 (lambda (key . args)
-                   (display
-                    (simple-format
-                     #f
-                     "
-error: ~A: ~A
-error: could not insert log part: '~A'\n\n"
-                     key args line))
+             (if (eof-object? line)
+                 (simple-format #t "finished reading logs for ~A\n"
+                                job-id)
+                 (let ((line-with-newline
+                        (string-append line "\n")))
                    (catch #t
                      (lambda ()
-                       (insert
-                        logging-conn
-                        job-id
+                       (insert logging-conn job-id line-with-newline)
+                       (display line-with-newline))
+                     (lambda (key . args)
+                       (display
                         (simple-format
                          #f
                          "
+error: ~A: ~A
+error: could not insert log part: '~A'\n\n"
+                         key args line))
+                       (catch #t
+                         (lambda ()
+                           (insert
+                            logging-conn
+                            job-id
+                            (simple-format
+                             #f
+                             "
 guix-data-service: error: missing log line: ~A
 \n" key)))
-                     (lambda _
-                       #t)))))
-             (loop (get-line port-to-read-from)))))))
+                         (lambda _
+                           #t))))
+                   (loop (get-line port-to-read-from)))))))))
 
      port-to-write-to)))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]