<#1923 Use communicate in shell task> Pull request...
# flyte-github
a
#1923 Use communicate in shell task Pull request opened by eapolinario TL;DR Use a different method to wait for child task in a ShellTask Type ☑︎ Bug Fix ☐ Feature ☐ Plugin Are all requirements met? ☑︎ Code completed ☑︎ Smoke tested ☑︎ Unit tests added ☐ Code documentation added ☐ Any pending items have an associated Issue Complete description The current implementation of
ShellTask
might hit the deadlock described in https://docs.python.org/3/library/subprocess.html#subprocess.Popen.wait if the child process ends up writing more than the pipe buffer size (which in most Linux systems sits around 65KB, or 16 pages). The fix is to use Popen.communicate, which waits for the process to terminate and returns a tuple
(stdout_data, stderr_data)
. The one downside of this is that it keeps both stdout and stderr in memory. We might expose a flag to use the slower method of using temporary files to hold the child process's stdout and stderr in the future. The test I added demonstrates the deadlock with the old code. Tracking Issue flyteorg/flyte#4313 Follow-up issue NA OR https://github.com/flyteorg/flyte/issues/ flyteorg/flytekit Codecov: 54.71% (-0.01%) compared to 4d5e1b8 Codecov: 0.00% of diff hit (target 54.71%) ✅ 28 other checks have passed 28/30 successful checks