Skip to content

Commit 3379ffb

Browse files
committed
fix: consume whole exec output
1 parent 76e552c commit 3379ffb

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

server/docker.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -256,24 +256,20 @@ def _parse_path(path: str):
256256

257257
async def _exec_output(container: DockerContainer, cmd: List[str], timeout=10, **kwargs):
258258
process = await container.exec(cmd=cmd, **kwargs)
259-
async with process.start() as exe:
260-
timeout_ctr = 0
259+
async with process.start(timeout=timeout) as exe:
261260
while True:
262261
details = await process.inspect()
263262
if details['Running']:
264-
if timeout:
265-
timeout_ctr += 1
266263
await asyncio.sleep(.1)
267-
if timeout_ctr > timeout * 10:
268-
break
269264
else:
270265
break
271266
details = await process.inspect()
272267
if details['ExitCode'] != 0:
273-
raise Exception('error reading directory')
274-
msg = await exe.read_out()
275-
if msg:
276-
return msg.data.decode('utf8')
268+
raise Exception('error executing command')
269+
msg = ''
270+
while part := await exe.read_out():
271+
msg += part.data.decode('utf8')
272+
return msg
277273

278274

279275
async def list_directory(username: str, container_id: str, path: str):

0 commit comments

Comments
 (0)