lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Wed, Nov 16, 2011 at 9:12 AM, Benoit Germain <bnt.germain@gmail.com> wrote:

Do you get the same kind of behavior with lanes that don't do
os.execute? For example, if you do:

local lanes = require "lanes".configure(1)
print( os.date())
local linda = lanes.linda()
lanes.gen("os,base", function() linda:receive(10, "null")
print("finished_sleeping " .. os.date()) end)()
lanes.gen("os,base", function() linda:receive(10, "null")
print("finished_sleeping " .. os.date()) end)()
lanes.gen("os,base", function() linda:receive(10, "null")
print("finished_sleeping " .. os.date()) end)()
lanes.gen("os,base", function() linda:receive(10, "null")
print("finished_sleeping " .. os.date()) end)()

Maybe this is related to the way os.execute works?


Yes that seems to work as expected.

Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
> dofile "test_lanes2.lua"
Wed Nov 16 19:51:15 2011
> finished_sleeping Wed Nov 16 19:51:25 2011
finished_sleeping Wed Nov 16 19:51:25 2011finished_sleeping Wed Nov 16 19:51:25 2011finished_sleeping Wed Nov 16 19:51:25 2011

I was using Lanes to execute multiple Lua interpreters with os.execute. These parallel processes then load a self-contained script which holds multiple os.execute statements internally to run various programs in sequence. 

It was always on my todo list to refactor this to load chunks of lua code with dofile or something instead of launching new lua interperters, but the scripts themselves still need os.execute to run the other applications. What's a better pattern to do such a thing and can I make it compatible with Lanes this way? 

Tomorrow I have time and access to ubuntu again so I'll repeat the tests there. 

Thanks for all the help so far.

Thijs