diff --git a/Pipfile b/Pipfile index 3f997b15..a342feb6 100644 --- a/Pipfile +++ b/Pipfile @@ -2,7 +2,7 @@ flake8 = ">=3.3.0,<4" pytest = "*" mock = "*" -"delegator.py" = ">=0.0.10" +"delegator.py" = ">=0.0.12" toml = "*" Sphinx = "<=1.5.5" diff --git a/pipenv/vendor/delegator.py b/pipenv/vendor/delegator.py index 55329593..491eb794 100644 --- a/pipenv/vendor/delegator.py +++ b/pipenv/vendor/delegator.py @@ -14,11 +14,14 @@ try: except NameError: STR_TYPES = (str, ) +TIMEOUT = 30 class Command(object): - def __init__(self, cmd): + + def __init__(self, cmd, timeout=TIMEOUT): super(Command, self).__init__() self.cmd = cmd + self.timeout = timeout self.subprocess = None self.blocking = None self.was_run = False @@ -48,7 +51,8 @@ class Command(object): def _default_pexpect_kwargs(self): return { 'env': os.environ.copy(), - 'encoding': 'utf-8' + 'encoding': 'utf-8', + 'timeout': self.timeout } @property @@ -185,16 +189,23 @@ class Command(object): else: self.subprocess.wait() - def pipe(self, command): + def pipe(self, command, timeout=None): """Runs the current command and passes its output to the next given process. """ + if not timeout: + timeout = self.timeout + if not self.was_run: self.run(block=False) data = self.out - c = Command(command) + if timeout: + c = Command(command, timeout) + else: + c = Command(command) + c.run(block=False) if data: c.send(data) @@ -225,13 +236,13 @@ def _expand_args(command): return command -def chain(command): +def chain(command, timeout=TIMEOUT): commands = _expand_args(command) data = None for command in commands: - c = run(command, block=False) + c = run(command, block=False, timeout=timeout) if data: c.send(data) @@ -242,11 +253,11 @@ def chain(command): return c -def run(command, block=True, binary=False): - c = Command(command) +def run(command, block=True, binary=False, timeout=TIMEOUT): + c = Command(command, timeout=timeout) c.run(block=block, binary=binary) if block: c.block() - return c + return c \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 590ea1ea..a2994768 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ Babel==2.4.0 backports.shutil-get-terminal-size==1.0.0 certifi==2017.4.17 chardet==3.0.3 -delegator.py==0.0.10 +delegator.py==0.0.12 docutils==0.13.1 funcsigs==1.0.2 idna==2.5