How to do something like, running 2 programs at once and if any will error then save the error to file (ex.) "/.log" ?
[Question] Multithreading ?
Started by mibac138, Apr 06 2014 02:03 PM
2 replies to this topic
#1
Posted 06 April 2014 - 02:03 PM
#2
Posted 06 April 2014 - 02:29 PM
function firstprogram()
func, error = loadfile("testone")
if not func then
h = fs.open("log", "a")
h.writeLine(error)
h.close()
else
pcall(func)
end
end
function secondprogram()
func, error = loadfile("testtwo")
if not func then
h = fs.open("log", "a")
h.writeLine(error)
h.close()
else
pcall(func)
end
end
parallel.waitForAll(firstprogram, secondprogram)
Untested, might not work. I am not so good with loadfile.
#3
Posted 06 April 2014 - 02:38 PM
You forgot to log the error resulting from the file's execution(pcall). Im curious though, why would you need to do such a thing? My experience with the parallel API is limited, but wouldn't your program crash and display the error as normal if you did not do this? Logging it seems somewhat... redundant.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











