script optimization to avoid uWSGI restart