aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2020-10-04 15:36:38 +0100
committerChristopher Baines <mail@cbaines.net>2020-10-04 15:38:31 +0100
commit888d9fcb98c6d697120993efe0b3bbd175bf37d7 (patch)
tree2652562d9104d048ea61cbe1bcd96366c5a9361a
parenta8d5ea4654b2a8e429fa6e6ee0f4366bc489ded4 (diff)
downloaddata-service-888d9fcb98c6d697120993efe0b3bbd175bf37d7.tar
data-service-888d9fcb98c6d697120993efe0b3bbd175bf37d7.tar.gz
Avoid locking up the thread pool channel on letpar& exceptions
Previously, if an exception occurred during the processing of any but the last letpar& expression, the replies for the other expressions would never be fetched, resulting in that thread in the pool just waiting for a receiver for the message. To avoid this, make sure to read all the replies before raising any exceptions.
-rw-r--r--guix-data-service/utils.scm12
1 files changed, 11 insertions, 1 deletions
diff --git a/guix-data-service/utils.scm b/guix-data-service/utils.scm
index cc9b7ac..8ad60f9 100644
--- a/guix-data-service/utils.scm
+++ b/guix-data-service/utils.scm
@@ -111,6 +111,16 @@
(result
(apply values result))))
+(define (fetch-result-of-defered-thunks . reply-channels)
+ (let ((responses (map get-message reply-channels)))
+ (map
+ (match-lambda
+ (('worker-thread-error . exn)
+ (raise-exception exn))
+ (result
+ (apply values result)))
+ responses)))
+
(define-syntax parallel-via-thread-pool-channel
(lambda (x)
(syntax-case x ()
@@ -120,7 +130,7 @@
(lambda ()
e0)))
...)
- (values (fetch-result-of-defered-thunk tmp0) ...)))))))
+ (apply values (fetch-result-of-defered-thunks tmp0 ...))))))))
(define-syntax-rule (letpar& ((v e) ...) b0 b1 ...)
(call-with-values