|
26 | 26 | import sys
|
27 | 27 | import tarfile
|
28 | 28 | import tempfile
|
29 |
| -from fcntl import fcntl, F_GETFL, F_SETFL |
30 | 29 | from six.moves.urllib.parse import urlparse
|
31 | 30 | from threading import Thread
|
32 | 31 |
|
@@ -105,7 +104,7 @@ def train(self, input_data_config, hyperparameters):
|
105 | 104 | compose_command = self._compose()
|
106 | 105 |
|
107 | 106 | _ecr_login_if_needed(self.sagemaker_session.boto_session, self.image)
|
108 |
| - process = subprocess.Popen(compose_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
| 107 | + process = subprocess.Popen(compose_command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
109 | 108 |
|
110 | 109 | try:
|
111 | 110 | _stream_output(process)
|
@@ -555,34 +554,20 @@ def __init__(self, host_dir, container_dir=None, channel=None):
|
555 | 554 | def _stream_output(process):
|
556 | 555 | """Stream the output of a process to stdout
|
557 | 556 |
|
558 |
| - This function takes an existing process that will be polled for output. Both stdout and |
559 |
| - stderr will be polled and both will be sent to sys.stdout. |
| 557 | + This function takes an existing process that will be polled for output. Only stdout |
| 558 | + will be polled and sent to sys.stdout. |
560 | 559 |
|
561 | 560 | Args:
|
562 | 561 | process(subprocess.Popen): a process that has been started with
|
563 |
| - stdout=PIPE and stderr=PIPE |
| 562 | + stdout=PIPE and stderr=STDOUT |
564 | 563 |
|
565 | 564 | Returns (int): process exit code
|
566 | 565 | """
|
567 | 566 | exit_code = None
|
568 | 567 |
|
569 |
| - # Get the current flags for the stderr file descriptor |
570 |
| - # And add the NONBLOCK flag to allow us to read even if there is no data. |
571 |
| - # Since usually stderr will be empty unless there is an error. |
572 |
| - flags = fcntl(process.stderr, F_GETFL) # get current process.stderr flags |
573 |
| - fcntl(process.stderr, F_SETFL, flags | os.O_NONBLOCK) |
574 |
| - |
575 | 568 | while exit_code is None:
|
576 | 569 | stdout = process.stdout.readline().decode("utf-8")
|
577 | 570 | sys.stdout.write(stdout)
|
578 |
| - try: |
579 |
| - stderr = process.stderr.readline().decode("utf-8") |
580 |
| - sys.stdout.write(stderr) |
581 |
| - except IOError: |
582 |
| - # If there is nothing to read on stderr we will get an IOError |
583 |
| - # this is fine. |
584 |
| - pass |
585 |
| - |
586 | 571 | exit_code = process.poll()
|
587 | 572 |
|
588 | 573 | if exit_code != 0:
|
|
0 commit comments