diff piecrust/baking/worker.py @ 702:c62d83e17abf

bake: Some more optimizations. Write the output files in a background thread to get away from the GIL.
author Ludovic Chabant <ludovic@chabant.com>
date Sat, 16 Apr 2016 22:50:07 -0700
parents 3bc9f857eb48
children ab5c6a8ae90a
line wrap: on
line diff
--- a/piecrust/baking/worker.py	Sat Apr 16 22:48:57 2016 -0700
+++ b/piecrust/baking/worker.py	Sat Apr 16 22:50:07 2016 -0700
@@ -81,6 +81,10 @@
                 'type': 'stats',
                 'data': data}
 
+    def shutdown(self):
+        for jh in self.job_handlers.values():
+            jh.shutdown()
+
 
 JOB_LOAD, JOB_RENDER_FIRST, JOB_BAKE = range(0, 3)
 
@@ -96,6 +100,9 @@
     def handleJob(self, job):
         raise NotImplementedError()
 
+    def shutdown(self):
+        pass
+
 
 def _get_errors(ex):
     errors = []
@@ -183,6 +190,9 @@
         super(BakeJobHandler, self).__init__(ctx)
         self.page_baker = PageBaker(ctx.app, ctx.out_dir, ctx.force)
 
+    def shutdown(self):
+        self.page_baker.shutdown()
+
     def handleJob(self, job):
         # Actually bake the page and all its sub-pages to the output folder.
         fac = load_factory(self.app, job['factory_info'])