On 27 August 2011 12:43, Chen Zheng <[email protected]> wrote: > Hi Graham, > > Thanks for the reply. > > On 27 August 2011 06:27, Graham Dumpleton <[email protected]> wrote: >> On 27 August 2011 04:04, Chen Zheng <[email protected]> wrote: >>> Hi, >>> >>> Due to some reason, I have to disable thread support in python >> >> Can you explain what the technical reason is? > > I'm working on some python hosting project, thread support is disabled > for management concern, anyway user is only allowed for one process > and one thread.
If you only allow for one concurrent request across whole web application then you will block some types of AJAX applications from working. A single thread only is also going to result in very poor application response under any reasonable load. The end result will be a quite poor user experience and not really what the Python web community is going to look very favourably on and want to use. Only people who know no better and are simply attracted by the cheap price will buy it and after they have signed up for one year to get their cheap rate, they will only feel ripped off when they find the service no good and can't do what they want. The Python community has had to suffer quite a bit with bad hosting in the past because of servers being configured for PHP and not taking into consideration the specific requirements of Python. The approach your management seems to be taking isn't improving anything and is actually even more restrictive than a lot of what has gone before. At least in PHP systems using FASTCGI you generally got multiple processes, even if they were still reaped in a way that was detrimental to Python even if fine for PHP. >>> and still thinking of using mod_wsgi. I just want to use the 'AddHandler >>> wsgi-script .py' way, like the cgi-script, only a little bit faster. >>> >>> No daemons in background, so one process per apache worker is enough, >>> is thread really necessary in this situation? >>> >>> Will a dummy thread or a fake WITH_THREAD work? Thanks. >> >> Although mod_wsgi supports threads and in daemon mode may even use >> some of its own background threads to keep things running, you >> yourself don't have to use a multithreaded configuration for handling >> of requests. > > Yes, I want single thread, or to be more precise, single process to > handle each request, how to config that? If you really want to force a single process/single request thread model you would have to use daemon mode. Just set threads=1 for the daemon process. This will not stop background threads which the user may want to create. If you completely disable that as well and make threads completely forbidden then you will break more applications and often why it isn't working will not be obvious and just upset users even more. If you really want to disable threading completely you may be better off using uWSGI as by default it works in that mode. FWIW, the original authors of uWSGI who also use it for their own web hosting service also thought disabling all threading was a good idea. They have though since realised it wasn't and themselves always enable threading now albeit no thread support is still the default in uWSGI. So happens I was talking to them about this very issue yesterday because that default mode of no threading support was breaking software I am writing and preventing it working under uWSGI. > Is wsgi-script handler mode single threaded? Everything in mod_wsgi goes through the same handler, the handler itself doesn't dictate the process/threading model. What dictates it is the Apache MPM if using embedded mode, or the daemon process configuration if using daemon mode, see: http://code.google.com/p/modwsgi/wiki/ProcessesAndThreading > If yes, thread support > is not needed, unless modwsgi still has a thread pool to care about > even in this mode. > > If thread support is really a must, is it possible to use a threaded > python to do all the management work, and a non-threaded python to > handle each request? No. Both activities occur in the same process. The whole point of the background threads, even when there is only a single request handler thread, is to check on the liveness of the process, monitor for shutdown triggers and kill the restart the process if it gets stuck. Just because of the way mod_wsgi daemon mode works with Apache this is done from within process and not by an external process. FWIW, I did a talk at PyCon in Sydney just gone and one of the issues I touched on is the poor Python support coming out of traditional web hosting companies with a PHP background. My overall opinion was that the Python web community should just give up on expecting decent service from them for Python and should just look forward to new style web hosting services without such a heritage or desire to just cram as many users as possible into as few as resources as possible. That just isn't a workable model for Python web applications as Python has quite different resource requirements to PHP. Graham > -jaime > > >> It is a bit hard to answer your question without knowing the technical >> reasons why you can't use an underlying Python implementation that >> supports threading. Your comment about what you want in the way of >> 'one process per apache worker' suggests you don't actually know how >> mod_wsgi works as it is. >> >> So, can we start with the reason first and work from there to what >> options you may have? >> >> Graham >> >> -- >> You received this message because you are subscribed to the Google Groups >> "modwsgi" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/modwsgi?hl=en. >> >> > > -- > You received this message because you are subscribed to the Google Groups > "modwsgi" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/modwsgi?hl=en. > > -- You received this message because you are subscribed to the Google Groups "modwsgi" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/modwsgi?hl=en.
