Closed srdgame closed 1 year ago
sched.run(function() local A=sched.run(function() print("A says: going to sleep couple seconds") sched.sleep(0)
By changing the sleep(2) to sleep(0) the programing runs well with lua 5.2.3.
Set the log level to ALL
lua cch@cch-NV47H:~/mycode/lua/lumen/tests$ lua test.lua A says: going to sleep couple seconds 2014/05/08 19:09:04 SCHED-DETAIL: task table: 0x16cd5d0 created waitd table: 0x16e73e0 B says: waiting for a A to die 2014/05/08 19:09:04 SCHED-DETAIL: task table: 0x16d65a0 created waitd table: 0x16d79f0 0 says: waiting for a 'ev' from A 2014/05/08 19:09:04 SCHED-DETAIL: task table: 0x16c53f0 created waitd table: 0x16df620 2014/05/08 19:09:04 SCHED-INFO: Started. cch@cch-NV47H:~/mycode/lua/lumen/tests$ /usr/local/openresty/luajit/bin/luajit-2.1.0-alpha test.lua A says: going to sleep couple seconds 2014/05/08 19:09:17 SCHED-DETAIL: task table: 0x40ce5050 created waitd table: 0x40ce5190 B says: waiting for a A to die 2014/05/08 19:09:17 SCHED-DETAIL: task table: 0x40ce5dc0 created waitd table: 0x40ce61b0 0 says: waiting for a 'ev' from A 2014/05/08 19:09:17 SCHED-DETAIL: task table: 0x40ce4a98 created waitd table: 0x40ce5de8 2014/05/08 19:09:17 SCHED-INFO: Started. A says: emittig 'ev, data!' 2014/05/08 19:09:19 SCHED-DEBUG: task table: 0x40ce5050 emitting event ev with 1 parameters 0 says: received a 'ev' from A, with: data! 0 says: going to kill A 2014/05/08 19:09:19 SCHED-DETAIL: killing table: 0x40ce5050 from table: 0x40ce4a98 B says: hear that A died B says: going to error with message 'xxx' 2014/05/08 19:09:19 SCHED-WARNING: table: 0x40ce5dc0 die on error, returning 1 parameters: test.lua:25: xxx 0 says: finishing, returning data! 2014/05/08 19:09:19 SCHED-DETAIL: table: 0x40ce4a98 returning 1 parameters 2014/05/08 19:09:19 SCHED-INFO: Finished. cch@cch-NV47H:~/mycode/lua/lumen/tests$
The issue is from the lib/idle.lua
Below is the fix.
local function unix_idle (t)
local ret = os.execute('sleep '..t)
if _VERSION =='Lua 5.1' and ret ~= 0
or (_VERSION =='Lua 5.2' or _VERSION == "Lua 5.3") and ret ~= true then
os.exit()
end
end
or Just remove the (_VERSION =='Lua 5.2' or _VERSION == "Lua 5.3")
Thank you, commited.
I have the same problem with LuaJIT as installed from torch (currently LuaJIT 2.1.0-beta1) on linux, which also reports _VERSION=='Lua 5.1'.
The ugly but explicit version fix following the above is:
local ret = os.execute('sleep '..t) if _VERSION =='Lua 5.1' and type(jit) ~= 'table' and ret ~= 0 or _VERSION ~='Lua 5.1' and ret ~= true or _VERSION =='Lua 5.1' and type(jit) == 'table' and ret ~= true then os.exit() end
but from my limited testing it seems you can just do:
local ret = os.execute('sleep '..t) if ret == 0 or ret == true then return end os.exit()
The second form works on Lua 5.2 on mac OSX and linux/LuaJIT as above.
Thanks, I pushed your second option (and left the first commented as documentation)
Hi,
It does not work with lua 5.2.3 in my laptop, (Ubuntu Gnome 14.04 amd64). It works with luajit from openresty. Below is the result running test.lua:
cch@cch-NV47H:~/mycode/lua/lumen/tests$ lua test.lua A says: going to sleep couple seconds B says: waiting for a A to die 0 says: waiting for a 'ev' from A cch@cch-NV47H:~/mycode/lua/lumen/tests$ /usr/local/openresty/luajit/bin/luajit-2.1.0-alpha test.lua A says: going to sleep couple seconds B says: waiting for a A to die 0 says: waiting for a 'ev' from A A says: emittig 'ev, data!' 0 says: received a 'ev' from A, with: data! 0 says: going to kill A B says: hear that A died B says: going to error with message 'xxx' 2014/05/08 18:22:46 SCHED-WARNING: table: 0x406949a0 die on error, returning 1 parameters: test.lua:25: xxx 0 says: finishing, returning data! cch@cch-NV47H:~/mycode/lua/lumen/tests$