Commits

Johannes Köster  committed 6b5cbc9

Better handling of BrokenPipeError.

  • Participants
  • Parent commits 1d32c66

Comments (0)

Files changed (2)

File snakemake/__init__.py

                         subsnakemake=subsnakemake
                         )
 
+    except BrokenPipeError:
+        # ignore this exception and stop. It occurs if snakemake output is piped into less and less quits before reading the whole output.
+        # in such a case, snakemake shall stop scheduling and quit with error 1
+        success = False
     except (Exception, BaseException) as ex:
         print_exception(ex, workflow.linemaps)
         success = False

File snakemake/logging.py

                 self.stream.write(self.decorate(record))
                 self.stream.write(getattr(self, 'terminator', '\n'))
                 self.flush()
-            except (KeyboardInterrupt, SystemExit, BrokenPipeError):
+            except BrokenPipeError as e:
+                raise e
+            except (KeyboardInterrupt, SystemExit):
                 # ignore any exceptions in these cases as any relevant messages have been printed before
                 pass
             except Exception as e: