diff options
author | Christopher Baines <mail@cbaines.net> | 2022-10-16 21:44:46 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2022-10-16 21:44:46 +0100 |
commit | 26fe4a780463d56d594e71b09025a7176753d976 (patch) | |
tree | 4ed9c7278795ece0ca495ec296e1524f8c839ecc | |
parent | f051c28c0d5882ba94570ef1e525567bbed0254d (diff) | |
download | build-coordinator-26fe4a780463d56d594e71b09025a7176753d976.tar build-coordinator-26fe4a780463d56d594e71b09025a7176753d976.tar.gz |
Raise exceptions when port-poll times out
Otherwise port-poll will just be called again.
-rw-r--r-- | guix-build-coordinator/utils.scm | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/guix-build-coordinator/utils.scm b/guix-build-coordinator/utils.scm index 9a83358..9877224 100644 --- a/guix-build-coordinator/utils.scm +++ b/guix-build-coordinator/utils.scm @@ -305,10 +305,29 @@ upcoming chunk." gc-enable) (thunk))) +(define &port-timeout + (make-exception-type '&port-timeout + &external-error + '())) + +(define make-port-timeout-error + (record-constructor &port-timeout)) + +(define port-timeout-error? + (record-predicate &port-timeout)) + (define* (with-port-timeouts thunk #:key (timeout (* 120 1000))) (parameterize - ((current-read-waiter (lambda (port) (port-poll port "r" timeout))) - (current-write-waiter (lambda (port) (port-poll port "w" timeout)))) + ((current-read-waiter + (lambda (port) + (when (eq? (port-poll port "r" timeout) 0) + (raise-exception + (make-port-timeout-error))))) + (current-write-waiter + (lambda (port) + (when (eq? (port-poll port "w" timeout) 0) + (raise-exception + (make-port-timeout-error)))))) (thunk))) (define* (make-chunked-output-port* port #:key (keep-alive? #f) |