storborg / pyramid_frontend

Theme handling, image filtering, and asset optimization for Pyramid
Other
0 stars 2 forks source link

Image generation failure can cause a lockfile to be left in place, blocking that image forever #32

Closed storborg closed 9 years ago

storborg commented 9 years ago

If the interpreter is killed during the chain processing for an image variant, the dogpile protection lockfile will be left in place forever, causing successive requests for that image to just block.

Troublesome code is here: https://github.com/storborg/pyramid_frontend/blob/master/pyramid_frontend/images/view.py#L52

It looks like it may be possible to add a timeout to the lock acquisition call, and force the lock to be broken if the timeout is exceeded. An example is on this page, but I think that example could be modified to use try/finally to be more robust to failures during image generation (which are especially likely to happen when shelling out to image processing utilities like convert, optipng, etc). http://pythonhosted.org/lockfile/lockfile.html

storborg commented 9 years ago

This doesn't seem to have ever happened in production, so it's ok for now.