branch: externals/el-job
commit e8d4c8e63e6cb7da4db2cef5cc933441972b7119
Author: Martin Edström <meedst...@runbox.eu>
Commit: Martin Edström <meedst...@runbox.eu>

    Attempt a graceful degradation
---
 el-job.el | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/el-job.el b/el-job.el
index a64d2f6aba..948663b821 100644
--- a/el-job.el
+++ b/el-job.el
@@ -583,9 +583,17 @@ should trigger `el-job--handle-output'."
                                            .n-cores-to-use
                                            .past-elapsed))
           busy-bufs)
+      ;; Sanity check
       (unless (length< splits (1+ (length .ready)))
-        (error "el-job: Items split in %d lists, but only %d ready processes"
-               (length splits) (length .ready)))
+        (if (or .busy (length= .ready 0))
+            (error "el-job: Items split in %d lists, but only %d ready 
processes (and %d busy)"
+                   (length splits) (length .ready) (length .busy))
+          (warn "el-job: Items split in %d lists, but only %d ready processes. 
%s"
+                (length splits) (length .ready)
+                "Falling back to use 1 process")
+          (mapc #'delete-process (cdr .ready))
+          (setf .ready (list (car .ready)))
+          (setq splits (list .queued-inputs))))
       (let ((print-length nil)
             (print-level nil)
             (print-circle t)

Reply via email to