Read from a pipe ignoring EINTR errors. This is necessary because when reading from pipes with GUI event loops running in the background, often interrupts are raised that stop the command from completing.
(p)
| 26 | #----------------------------------------------------------------------------- |
| 27 | |
| 28 | def read_no_interrupt(p): |
| 29 | """Read from a pipe ignoring EINTR errors. |
| 30 | |
| 31 | This is necessary because when reading from pipes with GUI event loops |
| 32 | running in the background, often interrupts are raised that stop the |
| 33 | command from completing.""" |
| 34 | import errno |
| 35 | |
| 36 | try: |
| 37 | return p.read() |
| 38 | except IOError as err: |
| 39 | if err.errno != errno.EINTR: |
| 40 | raise |
| 41 | |
| 42 | |
| 43 | def process_handler(cmd, callback, stderr=subprocess.PIPE): |
no test coverage detected