I suppose it doesn't matter that it's the timer facility that's
providing the async nature; what is the true problem is that I'm
calling certain API calls from within a coroutine.  If I weren't
convinced it would crash my current session at work, I would expect the
following code to also crash awesome:

local co = coroutine.create(function()
  notify { title = 'Alert!', text = 'hello' }
end)
coroutine.resume(co)

Thanks for the hint, though!  I was thinking about fleshing out my
async module with more functionality than just sleeping for a time!

-Rob

On Wed, 1 Oct 2014 12:57:44 -0400
"Elv1313 ." <elv1...@gmail.com> wrote:

> Hello Rob,
> 
> You might want to take a little look at LGI code for this. They have
> multiple trick to make this work. You can also use it for some async
> operation like "run when idle"
> 
> glib.idle_add(glib.PRIORITY_DEFAULT_IDLE, function() print("foo") end)
> 
> or async I/O information transfer:
> https://github.com/Elv13/awesome-configs/blob/master/utils/fd_async.lua
> 
> but overall I like your idea, it would be a nice addition to the yet
> to be officially proposed gears.async module.
> 
> Have a good day
> 
> On 1 October 2014 08:40, Rob Hoelz <rob.ho...@skinnycorp.com> wrote:
> > Hello Awesome developers,
> >
> > I've encountered an interesting behavior in Awesome while playing
> > with coroutines and timers (in an effort to develop a framework
> > where one can write synchronous-looking code that runs in an
> > asynchronous fashion).  In short, I am able to make Awesome
> > segfault when using certain Awesome API functions from within a
> > coroutine.
> >
> > Here's some example code:
> >
> > local sd     = require 'sleep-dealer'
> > local notify = require('naughty').notify
> >
> > sd.tuck_in(function()
> >   for i = 1, 5 do
> >     sd.sleep(1)
> >     notify {
> >       title = 'Alert!',
> >       text  = tostring(i),
> >     }
> >   end
> > end)
> >
> > The source for sleep-dealer.lua can be found here:
> > https://github.com/hoelzro/awesome-config/blob/8bb989a10ee52bfb0d42efcc486b2136585b0126/sleep-dealer.lua
> >
> > When naughty.notify is called, a segfault occurs.  I've determined
> > that this is because globalconf.L is used in a lot of Lua API calls.
> > Sometimes the Lua state passed into a function is really the state
> > corresponding to a coroutine, so the states don't match and Lua
> > panics.
> >
> > I bring this up here on the mailing list rather than fixing it
> > myself or filing a bug because I wanted to take the pulse of the
> > developer community on whether this is a true bug or if this is
> > doing something with Awesome that it wasn't intended for.  If it's
> > the latter, I can let the matter rest; if it's the former, I would
> > be happy to contribute a patch that fixes the problem.
> >
> > -Rob
> >
> > --
> > To unsubscribe, send mail to awesome-devel-unsubscr...@naquadah.org.


-- 
To unsubscribe, send mail to awesome-devel-unsubscr...@naquadah.org.

Reply via email to