moving thread to wsgi