You simply cannot run long running processes in a web server, they are build to do the opposite and trying to force them to do it leads to ruin in the end.
Your best bet is to offload the long running function to a separate python process.
Have a look at celery: http://www.celeryproject.org/
You do something homegrown using Redis / RabbitMq and consuming program.
Your requirement that only one function runs at a time should be achievable with all three.
Note that the number of moving parts increases if you use this solution, instead of one process, you have at least three (webserver, redis /rabbitmq and your consumer). Since orchestrating that is annoying, you might want to use docker (and docker-compose) to simplify the orchestration, e.g. restarting a component or monitoring it.