On Aug 31, 2011, at 4:33 AM, Henri Heinonen wrote: > Is it possible to set priorities for web2py applications? > > I am running a web2py server with some simulation applications. When I > run them, the welcome application works very sluggishly so it seems to > a visitor of my web2py server that the server (or at least the welcome > page section) is down. I would like to set the priority of the welcome > application as high as possible.
I don't think that Python has much in the way of thread-priority support. If it's convenient, you might experiment with calling time.sleep(0) fairly frequently in your CPU-bound simulation app, perhaps in some inner loop, to yield to other threads. Another (or supplementary) approach is to serialize your simulations, which might take some refactoring. The idea here is to have a single thread that runs the simulations from a queue, one at a time, so only one simulation thread is contending for CPU resources. Or push the simulations into another process altogether, and use the OS's process priority mechanisms.

