Skip to content

Commit 769d8e2

Browse files
authored
Revert "simplify run_interactive, pipeline can now accept an IOBuffer" (#199)
This reverts commit 18cc881.
1 parent 385c5e6 commit 769d8e2

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

src/DockerRunner.jl

+15-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,21 @@ function run_interactive(dr::DockerRunner, cmd::Cmd; stdin = nothing, stdout = n
212212

213213
try
214214
mount_shards(dr; verbose=verbose)
215-
return success(run(docker_cmd))
215+
if stdout isa IOBuffer
216+
if !(stdin isa IOBuffer)
217+
stdin = devnull
218+
end
219+
process = open(docker_cmd, "r", stdin)
220+
@async begin
221+
while !eof(process)
222+
write(stdout, read(process))
223+
end
224+
end
225+
wait(process)
226+
return success(process)
227+
else
228+
return success(run(docker_cmd))
229+
end
216230
finally
217231
unmount_shards(dr; verbose=verbose)
218232
# Cleanup permissions, if we need to.

src/UserNSRunner.jl

+16-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function UserNSRunner(workspace_root::String;
6262
sandbox_cmd = `$sandbox_cmd --verbose`
6363
end
6464
sandbox_cmd = `$sandbox_cmd --rootfs $(mpath)`
65-
if cwd !== nothing
65+
if cwd != nothing
6666
sandbox_cmd = `$sandbox_cmd --cd $cwd`
6767
end
6868

@@ -204,7 +204,21 @@ function run_interactive(ur::UserNSRunner, user_cmd::Cmd; stdin = nothing, stdou
204204

205205
try
206206
mount_shards(ur; verbose=verbose)
207-
return success(run(cmd))
207+
if stdout isa IOBuffer
208+
if !(stdin isa IOBuffer)
209+
stdin = devnull
210+
end
211+
process = open(cmd, "r", stdin)
212+
@async begin
213+
while !eof(process)
214+
write(stdout, read(process))
215+
end
216+
end
217+
wait(process)
218+
return success(process)
219+
else
220+
return success(run(cmd))
221+
end
208222
finally
209223
unmount_shards(ur)
210224
end

0 commit comments

Comments
 (0)