[uWSGI] Threads in lua ?
deco33 at hotmail.fr
Fri Apr 25 16:54:08 CEST 2014
I read the documentation and read the example codes, but cannot find a way to "spawn" functions to run in parallel in lua.
Any hints is greatly welcome !
From: deco33 at hotmail.fr
To: uwsgi at lists.unbit.it
Date: Fri, 25 Apr 2014 08:03:03 +0200
Subject: Re: [uWSGI] Threads in lua ?
So we will have to split our code into different apps then.
We cannot just do something like that :
local function one()
--do something long running (5s)
local function two()
--do something fast
local c,d = one,two
-- here spawn means execute
local e = c.spawn
local f = d.spawn
-- here readState means read the result or wait for it until it is done.
That way we could run in parallel inside the same app.
Is this behavior possible ?
> Date: Fri, 25 Apr 2014 07:32:29 +0200
> From: roberto at unbit.it
> To: uwsgi at lists.unbit.it
> Subject: Re: [uWSGI] Threads in lua ?
> > Hello,
> > I am not sure to understand : Lua is not multithreaded but uses
> > coroutines.
> > I would not rely on libraries to provide the parallel tasking (lanes,
> > llthread and so on) because of internal policies.
> > Yes, dumb but..
> > Will uwsgi help us in this field for lua ?
> > I thought about a rpc thing with sqlite to save the evolution but it is
> > not that interesting the end, because when the functions will not finish
> > at the same time you have to sleep for an arbitrary time and it is not a
> > reliable strategy (what if I sleep for one second and the process finished
> > 100 ms after the sleep ? 900 ms lost.)
> > I would like to spawn functions and get the whole result in the end.
> > Thanks
> > _______________________________________________
> uWSGI will generate a lua_state for every thread (if run in multithreaded
> mode). So yes, with uWSGI you can have multiple threads running the same
> lua app (without shared state)... and thanks to caches, queues and locks
> (and rpc to some extent) uWSGI apis you can have shared states at various
> Roberto De Ioris
> uWSGI mailing list
> uWSGI at lists.unbit.it
uWSGI mailing list
uWSGI at lists.unbit.it
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the uWSGI