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.
(stream: IO[bytes])
| 30 | #----------------------------------------------------------------------------- |
| 31 | |
| 32 | def read_no_interrupt(stream: IO[bytes]) -> bytes | None: |
| 33 | """Read from a pipe ignoring EINTR errors. |
| 34 | |
| 35 | This is necessary because when reading from pipes with GUI event loops |
| 36 | running in the background, often interrupts are raised that stop the |
| 37 | command from completing.""" |
| 38 | import errno |
| 39 | |
| 40 | try: |
| 41 | return stream.read() |
| 42 | except IOError as err: |
| 43 | if err.errno != errno.EINTR: |
| 44 | raise |
| 45 | return None |
| 46 | |
| 47 | |
| 48 | def process_handler( |
no test coverage detected
searching dependent graphs…