vmalloc/infi.execute — pull request #5 by grzn (2012-03-28 22:57:20+00:00)
Title: Retry reading from pipe in case of IOError 11

```python
In [36]: execute_assert_success('service sshd restart'.split())
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (12, 0))

---------------------------------------------------------------------------
IOError Traceback (most recent call last)
/root/ in ()
----> 1 execute_assert_success('service sshd restart'.split())

/root/python/lib/python2.7/site-packages/infi.execute-0.0.4-py2.7.egg/infi/execute/runner.pyc in execute_assert_success(self, *args, **kwargs)
20 def execute_assert_success(self, *args, **kwargs):
21 kwargs.update(assert_success=True)
---> 22 return self.execute(*args, **kwargs)
23 class LocalRunner(Runner):
24 def popen(self, *args, **kwargs):

/root/python/lib/python2.7/site-packages/infi.execute-0.0.4-py2.7.egg/infi/execute/runner.pyc in execute(self, *args, **kwargs)
16 def execute(self, *args, **kwargs):
17 returned = self.execute_async(*args, **kwargs)
---> 18 returned.wait()
19 return returned
20 def execute_assert_success(self, *args, **kwargs):

/root/python/lib/python2.7/site-packages/infi.execute-0.0.4-py2.7.egg/infi/execute/result.pyc in wait(self, timeout)
97 string_io.write(data)
98 def wait(self, timeout=None):
---> 99 returned_results = wait_for_many_results([self], timeout=timeout)
100 returned = self in returned_results
101 if not returned and (self.get_deadline() or timeout):

/root/python/lib/python2.7/site-packages/infi.execute-0.0.4-py2.7.egg/infi/execute/waiting.pyc in wait_for_many_results(results, **kwargs)
18 current_time = time.time()
19 ioloop.do_iteration(_get_wait_interval(current_time, deadline))
---> 20 _sweep_finished_results(results, returned)
21 if not _should_still_wait(results, deadline=deadline):
22 break

/root/python/lib/python2.7/site-packages/infi.execute-0.0.4-py2.7.egg/infi/execute/waiting.pyc in _sweep_finished_results(results, returned)
43 if result is None:
44 continue
---> 45 result.poll()
46 if result.is_finished():
47 returned[index] = result

/root/python/lib/python2.7/site-packages/infi.execute-0.0.4-py2.7.egg/infi/execute/result.pyc in poll(self)
81 def poll(self):
82 self._popen.poll()
---> 83 self._check_return_code()
84 return self.get_returncode()
85 def _check_return_code(self):

/root/python/lib/python2.7/site-packages/infi.execute-0.0.4-py2.7.egg/infi/execute/result.pyc in _check_return_code(self)
87 if returncode is not None:
88 # Although the process died, there may be some data in the pipes left.

---> 89 self._flush_pipes()
90 if self._assert_success and returncode is not None and returncode != 0:
91 raise ExecutionError(self)

/root/python/lib/python2.7/site-packages/infi.execute-0.0.4-py2.7.egg/infi/execute/result.pyc in _flush_pipes(self)
93 for string_io, pipe in ((self._output, self._popen.stdout), (self._error, self._popen.stderr)):
94 if pipe:
---> 95 data = pipe.read(-1)
96 if data:
97 string_io.write(data)

IOError: [Errno 11] Resource temporarily unavailable
```