--- a/degal/commands/main.py Sun Jun 14 18:24:14 2009 +0300
+++ b/degal/commands/main.py Sun Jun 14 20:05:11 2009 +0300
@@ -1,4 +1,5 @@
from degal.command import command
+from degal.concurrent import task
from degal import templates
def render_image_html (ctx, image) :
@@ -16,28 +17,38 @@
# write output
tpl.render_file(image.html)
-def render_image_thumbs (image) :
+def update_image_thumbs (image) :
"""
- Render the thubmnails for the given image
+ Render the thubmnails for the given image, returning the image.
+
+ This /should/ be threadsafe.
"""
+
+ # this will unconditionally update the image
+ image.update()
- image.update()
+ return image
def render_folder_images (ctx, images, for_update=True) :
"""
Render the given series of images
"""
- # render them in parallel as required
- for image in images :
+ # XXX: this breaks force_html
+
+ # render the thumbnails concurrently
+ for image in ctx.concurrent.execute(
+ task(update_image_thumbs, image)
+
+ for image in images
+
+ # only test if not already filtered for update
+ # XXX: externalize logic
+ if for_update or ctx.config.force_thumb or image.stale()
+ ) :
# log image path
ctx.log_info("%s", image)
- # only test if not already filtered for update
- if for_update or ctx.config.force_thumb or image.stale() :
- # render output thumbs
- render_image_thumbs(image)
-
# render HTML
render_image_html(ctx, image)
@@ -45,7 +56,7 @@
# XXX: verify that this works
del image.img
-def render_folder_page (ctx, folder) :
+def render_folder_html (ctx, folder) :
"""
Render the .html output for one folder
"""
@@ -86,7 +97,7 @@
if new_images or ctx.config.force_html :
# update folder index
- render_folder_page(ctx, folder)
+ render_folder_html(ctx, folder)
ctx.log_info("%s - render %d/%d images", folder, len(new_images), image_count)