From d50c1877105d07d9576f922801f5b772c3b4a522 Mon Sep 17 00:00:00 2001 From: Ryan Ward Date: Thu, 3 Aug 2023 23:22:01 -0400 Subject: [PATCH] Not hard crashing when error is encountered --- init.lua | 2 +- integration/sharedExtensions/init.lua | 8 ----- tests/threadtests.lua | 45 +++++++++++++-------------- 3 files changed, 22 insertions(+), 33 deletions(-) diff --git a/init.lua b/init.lua index aa87d1f..7f2b811 100644 --- a/init.lua +++ b/init.lua @@ -2392,8 +2392,8 @@ function multi.error(self, err) end if multi.defaultSettings.error then error("^^^ " .. multi:getCurrentProcess():getFullName() .. " " .. multi:getCurrentTask().Type .. "\n" .. debug.traceback().."\n") - os.exit(1) end + os.exit(1) end function multi.success(...) diff --git a/integration/sharedExtensions/init.lua b/integration/sharedExtensions/init.lua index e7cb8c7..9b29a83 100644 --- a/integration/sharedExtensions/init.lua +++ b/integration/sharedExtensions/init.lua @@ -52,9 +52,6 @@ function multi:newProxy(list) c.is_init = false local multi, thread = nil, nil function c:init() - for i,v in pairs(self) do - print("Pattern",i,v) - end local multi, thread = nil, nil local function copy(obj) if type(obj) ~= 'table' then return obj end @@ -172,7 +169,6 @@ function multi:newProxy(list) return self end end - function c:getTransferable() local cp = {} local multi, thread = require("multi"):init() @@ -197,12 +193,8 @@ function multi:newProxy(list) proxy.funcs = self.funcs return proxy:init() end - for i,v in pairs(cp) do - print("TRANS", i, v) - end return cp end - self:create(c) return c end diff --git a/tests/threadtests.lua b/tests/threadtests.lua index 315cfb7..47fc9d3 100644 --- a/tests/threadtests.lua +++ b/tests/threadtests.lua @@ -55,9 +55,6 @@ multi:newThread("Scheduler Thread",function() multi_assert("Passing some args", a, "First argument is not as expected 'Passing some args'") multi_assert(true, e, "Argument e is not true!") multi_assert("table", type(f), "Argument f is not a table!") - for i,v in pairs(queue) do - print("Queue:",i,v) - end queue:push("done") end,"Passing some args", 1, 2, 3, true, {"Table"}).OnError(function(self,err) multi.error(err) @@ -195,25 +192,25 @@ multi:newThread("Scheduler Thread",function() local tloop = stp:newTLoop(nil, 1) - -- multi:newSystemThread("Testing proxy copy THREAD",function(tloop) - -- local multi, thread = require("multi"):init() - -- for i,v in pairs(tloop.funcs) do - -- print(i,v) - -- end - -- tloop = tloop:init() - -- multi.print("tloop type:",tloop.Type) - -- multi.print("Testing proxies on other threads") - -- thread:newThread(function() - -- while true do - -- thread.hold(tloop.OnLoop) - -- print(THREAD_NAME,"Loopy") - -- end - -- end) - -- tloop.OnLoop(function(a) - -- print(THREAD_NAME, "Got loop...") - -- end) - -- multi:mainloop() - -- end, tloop:getTransferable()).OnError(multi.error) + multi:newSystemThread("Testing proxy copy THREAD",function(tloop) + local multi, thread = require("multi"):init() + for i,v in pairs(tloop.funcs) do + print(i,v) + end + tloop = tloop:init() + multi.print("tloop type:",tloop.Type) + multi.print("Testing proxies on other threads") + thread:newThread(function() + while true do + thread.hold(tloop.OnLoop) + print(THREAD_NAME,"Loopy") + end + end) + tloop.OnLoop(function(a) + print(THREAD_NAME, "Got loop...") + end) + multi:mainloop() + end, tloop:getTransferable()).OnError(multi.error) multi.print("tloop", tloop.Type) multi.print("tloop.OnLoop", tloop.OnLoop.Type) @@ -240,8 +237,8 @@ multi:newThread("Scheduler Thread",function() end) t, val = thread.hold(function() - return proxy_test - end,{sleep=15}) + return count == 10 + end,{sleep=5}) if val == multi.TIMEOUT then multi.error("SystemThreadedProcessor/Proxies: Failed")