Lua Lanes: attempt to index global "os" (nil value)

I wanted to use Lua Lanes for multithreading and time recording. Here is the code:

require "lanes"

function performTest ()
    os.execute("testJson-mt.lua")
end

for i=1,10,1 do
    f= lanes.gen(performTest)
    a=f()
    startTime = os.time()
    print("ID "..a[1].." completed.")
    endTime = os.time()
    diff = os.difftime (endTime, startTime)
    print(i..","..os.date("%x %X",startTime)..","..os.date("%x %X",endTime)..","..startTime..","..endTime..","..diff)
end

However, when I run the code, the console returns an error: lua: testLanes.lua:4: attempt to index global 'os' (a nil value).

This error code points to this line where os.execute("testJson-mt.lua"). I do not quite understand this error. Please inform.

Note. I use Lua for Windows as a development environment.

+5
source share
2 answers

By default it lanes.gendoes not load libraries , even base libraries. Therefore, pass '*'in as the first parameter lanes.gento get osother modules in the strip.

+7

require "os".

+1

All Articles