Is it possible to make this work between mod_wsgi sub interpreters?
from threading import Thread
from multiprocessing import Queue
def sid(q):
u = 0
while True:
u += 1
q.put(u)
q = Queue(2)
t = Thread(target=sid, args=(q,))
t.daemon = True
t.start()
def application(environ, response):
o = str(q.get())
response('200 OK', [('Content-type', 'text/plain'),
('Content-Length', str(len(o)))])
return [o]
From Graham Dumpleton: If the multiprocessing module can only communicate between processes whereby one was forked from another, it cannot be used to communicate between mod_wsgi daemon mode or even Apache server child processes in embedded mode, as you can't run code in the parent process to the fork. Even then, not sure if multiprocessing module would allow you to communicate between peered child processes of the fork, or only back to the parent process.