Fix a bug occured when running as wsgi