diff options
-rw-r--r-- | guix-build-coordinator/utils.scm | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/guix-build-coordinator/utils.scm b/guix-build-coordinator/utils.scm index 27f1988..239fe9f 100644 --- a/guix-build-coordinator/utils.scm +++ b/guix-build-coordinator/utils.scm @@ -552,21 +552,31 @@ References: ~a~%" (when (q-empty? queue) (wait-condition-variable job-available queue-mutex)) - (let ((job-args (deq! queue))) - (set! running-jobs-count (+ 1 running-jobs-count)) - (unlock-mutex queue-mutex) - (with-exception-handler - (lambda (exn) - (simple-format (current-error-port) - "exception when handling job: ~A\n" - exn) - ;; Add the job back to the queue so that it's tried again - (apply process-job job-args)) - (lambda () - (apply proc job-args)) - #:unwind? #t) - (with-mutex queue-mutex - (set! running-jobs-count (- running-jobs-count 1)))) + (and=> + (with-exception-handler + (lambda (exn) + (simple-format (current-error-port) + "exception for deq!: ~A\n" + exn) + #f) + (lambda () + (deq! queue)) + #:unwind? #t) + (lambda (job-args) + (set! running-jobs-count (+ 1 running-jobs-count)) + (unlock-mutex queue-mutex) + (with-exception-handler + (lambda (exn) + (simple-format (current-error-port) + "exception when handling job: ~A\n" + exn) + ;; Add the job back to the queue so that it's tried again + (apply process-job job-args)) + (lambda () + (apply proc job-args)) + #:unwind? #t) + (with-mutex queue-mutex + (set! running-jobs-count (- running-jobs-count 1))))) (loop))))) (iota thread-count)) |