From 0d9afa4ced41f2c15d52e540a13815295da51d3f Mon Sep 17 00:00:00 2001 From: empathicqubit Date: Sat, 8 May 2021 00:07:52 -0400 Subject: [PATCH] Paranoid distrust of variable scoping --- runner-wrapper.lua | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/runner-wrapper.lua b/runner-wrapper.lua index 32f8608..85a7b29 100644 --- a/runner-wrapper.lua +++ b/runner-wrapper.lua @@ -174,8 +174,10 @@ return function(promise) message(_M, 'Waiting for child processes to finish') - local function readLoop(outputPipe, line) + local function readLoop(outputPipe) return util.promiseWrap(function() + return outputPipe:read("*l") + end):next(function(line) if line == nil or line == "" then util.closeCmd(outputPipe) end @@ -216,19 +218,14 @@ return function(promise) return end - local line = outputPipe:read("*l") - return readLoop(outputPipe, line) + return readLoop(outputPipe) end) end local waiters = {} for i=1,#speciesSlice,1 do local outputPipe = _M.poppets[i].output - local waiter = util.promiseWrap(function() - local line = outputPipe:read("*l") - - return readLoop(outputPipe, line) - end) + local waiter = readLoop(outputPipe) table.insert(waiters, waiter) end