branch: main
commit 69da0ac4f69f2204caaa72ac64448c0bbeb91aa0
Author: Ludovic Courtès <l...@gnu.org>
AuthorDate: Tue Mar 18 15:58:04 2025 +0100

    base: ‘event-log’ relays events asynchronously.
    
    * src/cuirass/base.scm (event-log-service): Do not rely
    ‘derivation-built’ messages to subscribers.  Relay messages to
    subscribers in a new fiber.
---
 src/cuirass/base.scm | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/src/cuirass/base.scm b/src/cuirass/base.scm
index d62960e..51d361c 100644
--- a/src/cuirass/base.scm
+++ b/src/cuirass/base.scm
@@ -841,11 +841,16 @@ notification subscriptions."
                    (when build
                      (put-message channel
                                   `(new-event (build-status-changed 
,build))))))))
-             (_ #t))
-           ;; For now, every new event is sent to all subscribers.
-           (for-each (lambda (reply)
-                       (put-message reply data))
-                     subscribers)
+             (_
+              ;; For now, every new event is sent to all subscribers.  Since
+              ;; processing of the event by subscribers might take time, do it
+              ;; concurrently to avoid blocking sources of events.
+              (spawn-fiber
+               (lambda ()
+                 (for-each (lambda (subscriber)
+                             (put-message subscriber data))
+                           subscribers)))))
+
            (loop events subscribers)))
         (`(recent-events ,reply)
          (put-message reply (ring-buffer->list events))

Reply via email to