Skip to content

Commit

Permalink
Fix race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
romain-intel committed Sep 13, 2024
1 parent 9c313df commit bb8f72a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions metaflow/runner/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ def read_from_file_when_ready(
content = file_pointer.read()
while not content:
if command_obj.process.poll() is not None:
# Check to make sure the file hasn't been read yet to avoid a race
# where the file is written between the end of this while loop and the
# poll call above.
content = file_pointer.read()
if content:
break
raise CalledProcessError(
command_obj.process.returncode, command_obj.command
)
Expand Down

0 comments on commit bb8f72a

Please sign in to comment.