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

Commit

Permalink
Stream first, write later
Browse files Browse the repository at this point in the history
  • Loading branch information
nhynes committed Sep 11, 2016
1 parent 0e54f85 commit f27e944
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,22 @@ shell_router.execute_request = function (sock, msg)
end
if func then
pok = true
-- TODO: for lua outputs to be streamed from the executing command (for example a long for-loop), redefine 'print' to stream-out pyout messages

local _print = print
local buf = ''
print = function(text)
buf = buf..text
iopub_router.stream(iopub, msg, 'stdout', text)
end

ok,err = xpcall(func, traceback)

local m = util.msg('clear_output', msg)
m.content = {wait=true, display=true}
util.ipyEncodeAndSend(iopub, m)

print = _print
print(buf)
else
ok = false;
err = perr;
Expand Down

0 comments on commit f27e944

Please sign in to comment.