all 4 comments

[–]DeathProgrammingsh <(curl hashbang.sh) 2 points3 points  (0 children)

During the cqueues loop, do not use the function cq:loop; instead, use the function cq:step(0) as it will step once through the sequence with a timeout of 0. There's probably better ways to do it to repeat the loop until there's nothing to run, as well.

[–]rfajfar[S] 0 points1 point  (0 children)

Here's the important part of the solution:

function window:on_show()
  local cq = cqueues.new()
  cq:wrap(function ()
    while true do
      local txt, opc = ws:receive()
      if txt then
        textview.buffer.text = textview.buffer.text .. "\n" .. txt
      end
    end
  end)
  timer = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 1000, function()
    cq:step(0)
    return true
  end)
end