SyncManager

This lesson discusses the SyncManager from the multiprocessing module which offers proxies for shared objects.

We'll cover the following...

Sync Manager

So far we have been using time.sleep() to delay the server manager from shutting down before other processes had a chance to retrieve shared objects from it. Obviously, this isn't a good strategy and we need a better way to coordinate among the different processes. Fortunately, there's a subclass of BaseManager called the SyncManager which offers proxies of synchronization constructs from the threading module. Let's revisit the example we discussed under the manager section where we used a timer to delay shutting down the manager. We'll replace the base manager with a sync manager and create a semaphore proxy using the sync manager. The main process would wait on the semaphore while the child process after accessing the shared objects would set the semaphore. The code appears below:

SyncManager implements tools for synchronizing ...