[Answer]-Deploying gevent in Django with mod_wsgi under Apache

1👍

You are correct that __name__ is not ‘__main__’ in mod_wsgi. Even without the if(), where in the WSGI script file did you place the monkey patch call? You don’t show that in what the WSGI script file looks like.

Overall, using gevent monkey patching in mod_wsgi is probably a bad idea anyway. This is because using gevent usually gives people a false sense of security that they no longer have to deal with thread locking because greenlets will to some degree order execution so for simple stuff it isn’t needed. It is most definitely a bad idea to rely on that under mod_wsgi because all the request handler threads will still be real threads and not greenlets because the threads are created as external threads using Apache thread APIs. Thus very much still need to handle thread locking properly.

One last thing. You may want to add to your question what you are trying to achieve in doing this, because your attempts at replacing the application with the WSGIHandler from gevent make no sense.

Leave a comment