From 7587098fb8bcd6d0f2100ab5386541bc841ff4c7 Mon Sep 17 00:00:00 2001 From: Doug Torrance Date: Thu, 21 Nov 2024 08:18:47 -0500 Subject: [PATCH] Raise an error when calling taskResult on an unscheduled task Otherwise, M2 hangs waiting for a task that will never start --- M2/Macaulay2/d/pthread.d | 2 ++ 1 file changed, 2 insertions(+) diff --git a/M2/Macaulay2/d/pthread.d b/M2/Macaulay2/d/pthread.d index 5a87ce2868..f396bba20f 100644 --- a/M2/Macaulay2/d/pthread.d +++ b/M2/Macaulay2/d/pthread.d @@ -209,6 +209,8 @@ setupfun("schedule",schedule); taskResult(e:Expr):Expr := ( when e is c:TaskCell do if c.body.resultRetrieved then buildErrorPacket("task result already retrieved") + else if !taskReady(c.body.task) + then buildErrorPacket("task not scheduled yet") else if !taskKeepRunning(c.body.task) then buildErrorPacket("task canceled") else if !taskDone(c.body.task) then ( Ccode(voidPointer, "waitOnTask(",c.body.task,")");