0

I am running a python thread pool under Apache2 to handle incoming special HTTP requests.

The idea is that I have a single "handler" thread per request source - so if I have three devices (A,B,C) sending me these special requests, each would have its own "handler" thread on the server (1-A, 2-B, 3-C)

I have a thread pool class defined like this:

class threadController(threading.Thread)
   threadPool = []

And when I get a new request, I look through all my running threads, to match a particular one, and pass the request to it.

This seemed to work well enough under Windows.

However, on Linux, it seems that sometimes my threadPool variable returns as empty, and I get an extra thread. So I have a single device (A) sending requests, but end up with two threads (1-A and 2-A).

Here's the strange thing: It is always one extra thread, never more. Regardless whether my device (A) sends 5 requests, or 30.

I am using mod_wsgi (3.3) for django integration.

Note: I realize that this is a somewhat unorthodox way of handling sessions. I am not looking for a way to handle sessions better - I already know there are better ways :)

1 Answer 1

1

On Windows there is only one Apache child process handling requests. On non Windows systems, if using embedded mode there can be multiple processes.

Use mod_wsgi daemon and its default of a single process. See:

http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide#Delegation_To_Daemon_Process

and:

http://code.google.com/p/modwsgi/wiki/ProcessesAndThreading

Sign up to request clarification or add additional context in comments.

1 Comment

Yes, this was exactly the problem, the MPM was different. I tweaked apache settings as per your second link, and it is working fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.