pafcu
pafcu

Reputation: 8128

Share data between mod_python processes

I'm running mod_python under Apache. If I've understood correctly, each Apache process runs its own Python interpreter.

What would be the best way to share a tiny amount of data across all the processes? I'm talking about just a few hundred bytes here, making something database based completely overkill.

Upvotes: 1

Views: 298

Answers (2)

D.Shawley
D.Shawley

Reputation: 59623

The quickest way is to use file IO. One process writes the file and the other reads it. You can use the mmap module to make this a little more seamless. One interesting alternative that I haven't tried (yet) is to use some derivative of multiprocessing.Manager to communicate between the processes. I haven't tried the latter, I was looking for some way to create a process-shared semaphore.

Upvotes: 1

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799300

Put it in shared memory.

Upvotes: 1

Related Questions