Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
Stream instead of print
Browse files Browse the repository at this point in the history
  • Loading branch information
nhynes committed Sep 11, 2016
1 parent c660b3e commit 0e54f85
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
17 changes: 8 additions & 9 deletions gfx.lua
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,10 @@ if ok then
local _progress = xlua.progress
xlua.progress = function(i, n)
-- make progress bar really slow in itorch
if os.clock() - last > 1 then
if os.clock() - last > 1 or i == n then
local outstr = ''
io.write = function(s)
if s ~= '\r' then
if s ~= '\r' and s ~= '\n' then
outstr = outstr..s
end
end
Expand All @@ -231,17 +231,16 @@ if ok then
io.write = _write
io.flush = _flush

local m = util.msg('clear_output', itorch._msg)
m.content = {}
m.content.wait = true
m.content.display = true
util.ipyEncodeAndSend(itorch._iopub, m)
itorch._iopub_router.stream(itorch._iopub, itorch._msg, 'stdout', '\r'..outstr)

print(outstr)
-- local m = util.msg('clear_output', itorch._msg)
-- m.content = {}
-- m.content.wait = true
-- m.content.display = true
-- util.ipyEncodeAndSend(itorch._iopub, m)

last = os.clock()
end
-- itorch.html(progress_template % {})
end
end

Expand Down
1 change: 1 addition & 0 deletions main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ iopub_router.stream = function(sock, m, stream, text)
}
util.ipyEncodeAndSend(sock, o);
end
itorch._iopub_router = iopub_router -- for the display functions to have access

---------------------------------------------------------------------------
-- Shell router
Expand Down

0 comments on commit 0e54f85

Please sign in to comment.