2009/11/9 gert <
gert.c...@gmail.com>:
>
> On Nov 9, 12:40 am, Graham Dumpleton <
graham.dumple...@gmail.com>
> wrote:
>> 2009/11/9 gert <
gert.cuyk...@gmail.com>:
>>
>> > Session id's or barcodes for concert tickets etc.
>>
>> > But never mind that, it raises a much more interesting question. Can
>> > the built in multiprocessing module in python be able to work in a
>> > mod_wsgi environment ?
>>
>> If the multiprocessing module can only communicate between processes
>> whereby one was forked from another then no, 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.
>>
>> Why do you need the processes to communicate with each other?
>>
>
> There are lots of interesting stuff processes can tel to each other
> like, do not try to execute this because me process 1 is already
> calculating it, tell the user I will sent him a email in 5 minutes
> when its done so that he stops hitting the damn refresh button.
>
> Yes I know you communicate in other way's but
>
http://docs.python.org/library/multiprocessing.html is just the
> coolest one
> So what about a from modwsgi import multiprocessing :)
Not necessarily the coolest. It does have a low entry point though.
If you want to see something really awesome (scary), have a look at:
http://ose.sourceforge.net
http://ose.sourceforge.net/browse.php?group=python-manual&entry=manual.htm
It provides full request/reply and publish/subscribe messaging
infrastructure. I use it where I work across hundreds of sites and
thousands of machines. In one case the network of processes is
probably over 1500.
I have learnt more about how threading works in Python now so
technically needs to be tweaked a little to be truly conforming for
use in context of multiple sub interpreters, but that was implemented
so could be used in any sub interpreter in Apache processes, plus
allow one to communicate between sub interpreters as well as to other
processes.
Do note that this needs a central process to act as message exchange
if doing interprocess communications. But then, one can create a dummy
daemon process group and preload script to initialise it as such.
I really should go back and make sure it all works under mod_wsgi
since last time I played with it in conjunction with Apache was with
mod_python.
Graham