Dev and Test, Paste and Gunicorn

Tags: python devops

I’ve been working under an assumption: WSGI abstracts away all of the details of serving up a python web application so well that WSGI web server implementations are totally interchangeable without thought or worry.

WSGI is awesome, but not quite that awesome. Abstractions are leaky, it’s a law.

IronBlogger development has picked back up thanks to Julython, and the deployment went as planned until I restarted the process. It got stuck in an infinite loop of restarting itself, with exceptions thrown in the database initialization code.

I used the pip freeze command to dump lists of installed software in each host, and gunicorn was the only additional bit of code in the production environment. And, sensibly, the only difference outside of turning off live debugging was the gunicorn configuration:

[server:main]
use = egg:Paste#http
host = 0.0.0.0
port = 6543

INI
[server:main]
use = egg:gunicorn#main
host = 0.0.0.0
port = 6543
workers = 2
proc_name = ironblogger

INI

I haven’t figured out exactly what the problem is, but I’m getting close. This is primarily a public service announcement: test your code with the same server software that it’ll run on in production. Abstractions are leaky, and it may work for a while, but one day it won’t.