It needs a print statement or it will hang.
In the absence of any code, I will guess that it doesn't actually hang but instead times out. The web server and the web client will both have timeouts so that connections are not maintained indefinitely in the absence of data transfer. You can either avoid the timeouts by transferring some data (eg. the printing of dots which you've already found) or better yet you could restructure your code so that it runs in the background on the server and the client polls to determine when it has finished. The latter is generally accepted to be the better solution because it doesn't clog up the server with long-lived connections doing precious little.
There is of course a third option which is to optimise your code so that it produces results in a reasonably short time.