From ba219981185d90a926d6eff5b4629717133c77d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sun, 9 Aug 2020 23:25:40 +0200 Subject: Partial search page works, but alway times out first. --- module/vcomponent/search.scm | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/module/vcomponent/search.scm b/module/vcomponent/search.scm index 571279e7..65e2630a 100644 --- a/module/vcomponent/search.scm +++ b/module/vcomponent/search.scm @@ -45,13 +45,19 @@ ;; execute a query procedure created by build-query-proc. ;; (event → bool), int, (optional int) → (list event) throws 'timed-out (define* (execute-query query page key: (time-limit 1)) - (call-with-time-limit - time-limit - ;; Stream->list needs to be here, since the actual - ;; stream-force needs to happen within the actual - ;; @var{call-with-time-limit}. - (lambda () (stream->list (stream-ref query page))) - (lambda _ (throw 'timed-out)))) + (let ((lst '())) + (call-with-time-limit + time-limit + ;; Stream->list needs to be here, since the actual + ;; stream-force needs to happen within the actual + ;; @var{call-with-time-limit}. + (lambda () + (let loop ((strm (stream-ref query page))) + (if (stream-null? strm) lst + (set! lst (cons (stream-car strm) lst)) + (loop (stream-cdr strm))))) + (lambda _ (format (current-error-port) "~a~%" 'timed-out))) + (reverse lst))) ;; Creates a prepared query wrappend in a paginator. -- cgit v1.2.3