Skip to content

Commit

Permalink
BF: sleep a bit if there were no output in log_online mode to avoid 1…
Browse files Browse the repository at this point in the history
…00% load
  • Loading branch information
yarikoptic committed May 8, 2018
1 parent 6c44772 commit e3e8665
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions datalad/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"""


import time
import subprocess
import sys
import logging
Expand Down Expand Up @@ -296,10 +296,17 @@ def _get_output_online(self, proc,
# in another thread http://codereview.stackexchange.com/a/17959
# current problem is that if there is no output on stderr
# it stalls
# Monitor if anything was output and if nothing, sleep a bit
stdout_, stderr_ = None, None
if log_stdout_:
stdout += self._process_one_line(*stdout_args)
stdout_ = self._process_one_line(*stdout_args)
stdout += stdout_
if log_stderr_:
stderr += self._process_one_line(*stderr_args)
stderr_ = self._process_one_line(*stderr_args)
stderr += stderr_
if not (stdout_ or stderr_):
# no output was generated, so sleep a tiny bit
time.sleep(0.001)

# Handle possible remaining output
stdout_, stderr_ = proc.communicate()
Expand Down

0 comments on commit e3e8665

Please sign in to comment.