amitt001 / amitt001/delegator.py

hang on chain if pipe nothing to awk

Aberta
#73 0 comentários 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
Python
Estrelas
1.7k
Forks
86
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

`delegator.chain("printf '' | awk '{print $1}'")` would hang, while
`delegator.run("printf '' | awk '{print $1}'")` wouldn't.
It seems that the command would block in `pexpect`:
```
^C---------------------------------------------------------------------------
KeyboardInterrupt Traceback (most recent call last)
in
----> 1 delegator.chain("printf '' | awk '{print $1}'")

~/.pyenv/versions/3.7.0/lib/python3.7/site-packages/delegator.py in chain(command, timeout, cwd, env)
308 c.subprocess.sendeof()
309
--> 310 data = c.out
311
312 return c

~/.pyenv/versions/3.7.0/lib/python3.7/site-packages/delegator.py in out(self)
126 self.__out = self.std_out.read()
127 else:
--> 128 self.__out = self._pexpect_out
129
130 return self.__out

~/.pyenv/versions/3.7.0/lib/python3.7/site-packages/delegator.py in _pexpect_out(self)
114 result += self.subprocess.after
115
--> 116 result += self.subprocess.read()
117 return result
118

~/.pyenv/versions/3.7.0/lib/python3.7/site-packages/pexpect/spawnbase.py in read(self, size)
439 if size < 0:
440 # delimiter default is EOF
--> 441 self.expect(self.delimiter)
442 return self.before
443

~/.pyenv/versions/3.7.0/lib/python3.7/site-packages/pexpect/spawnbase.py in expect(self, pattern, timeout, searchwindowsize, async_, **kw)
339 compiled_pattern_list = self.compile_pattern_list(pattern)
340 return self.expect_list(compiled_pattern_list,
--> 341 timeout, searchwindowsize, async_)
342
343 def expect_list(self, pattern_list, timeout=-1, searchwindowsize=-1,

~/.pyenv/versions/3.7.0/lib/python3.7/site-packages/pexpect/spawnbase.py in expect_list(self, pattern_list, timeout, searchwindowsize, async_, **kw)
367 return expect_async(exp, timeout)
368 else:
--> 369 return exp.expect_loop(timeout)
370
371 def expect_exact(self, pattern_list, timeout=-1, searchwindowsize=-1,

~/.pyenv/versions/3.7.0/lib/python3.7/site-packages/pexpect/expect.py in expect_loop(self, timeout)
111 incoming = spawn.read_nonblocking(spawn.maxread, timeout)
112 if self.spawn.delayafterread is not None:
--> 113 time.sleep(self.spawn.delayafterread)
114 if timeout is not None:
115 timeout = end_time - time.time()

KeyboardInterrupt:
```

My delegator version is `0.1.1`

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.