Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python singleton into multiprocessing

How can I code to share the same instance of a "singletonic" class among processes?

like image 466
DrFalk3n Avatar asked Jul 10 '09 14:07

DrFalk3n


1 Answers

Best is to designate one specific process as owning that instance and dedicated to it; any other process requiring access to that instance obtains it by sending messages to the owning process via a Queue (as supplied by the multiprocessing module) or other IPC mechanisms for message passing, and gets answers back via similar mechanisms.

like image 76
Alex Martelli Avatar answered Nov 10 '22 05:11

Alex Martelli