Multiprocessing managers
Within the multiprocessing
module, we have the Manager
class; this class can be utilized as a means of controlling Python objects, and providing thread and process safety within your Python applications.
We can initialize a new Manager like this:
Import multiprocessing myManager = multiprocessing.Manager()
With this manager
object, we can then start to share things such as lists and dicts across multiple processes, and typically, it's the first port of call you'd go to if you needed to implement your own form of communication.
Namespaces
Managers come with this concept of namespaces; these namespaces feature no public methods that we can call, but they are useful in the sense that they have writable attributes.
In situations where you need a quick and dirty method for sharing several attributes across multiple processes, this is the prime candidate for doing so.
Example
In this example, we look at how to utilize namespaces in order to share some data across both a main process...