fix results stuff

This commit is contained in:
Jaremy Creechley 2024-05-17 01:36:04 +03:00
parent ebc284ae6a
commit 0bbd558ee7
No known key found for this signature in database
GPG Key ID: 4E66FB67B21D3300
2 changed files with 8 additions and 5 deletions

View File

@ -64,10 +64,6 @@ proc prove*[H](
let res: ?!CircomProof = failure(err)
return res
let sigRes = signal.close()
if sigRes.isErr:
return failure(sigRes.error())
let pf: CircomProof = proof
success(pf)

View File

@ -12,15 +12,22 @@ const
proc awaitThreadResult*[T](signal: ThreadSignalPtr, handle: Flowvar[T]): Future[?!T] {.async.} =
await wait(signal)
proc closeSig() =
let sigRes = signal.close()
if sigRes.isErr:
return failure(sigRes.error())
var
res: T
awaitTotal: Duration
while awaitTotal < CompletionTimeout:
if handle.tryComplete(res):
if handle.tryComplete(res): ## TODO: pretty sure this leaks currently
closeSig()
return success(res)
else:
awaitTotal += CompletionRetryDelay
await sleepAsync(CompletionRetryDelay)
closeSig()
return failure("Task signaled finish but didn't return any result within " & $CompletionRetryDelay)