What is UltraDict and how does it work?
mainUltraDict is a synchronized, streaming Python dictionary that uses multiprocessing.shared_memory as a backend to synchronize data between multiple processes.
Instead of transferring the entire dictionary, it uses a stream of updates in a shared memory buffer. This makes it efficient because only changes (deltas) are serialized and transferred.
Key Lifecycle Behavior:
- When the streaming buffer becomes full, UltraDict automatically performs a "full dump" to a new shared memory space.
- The streaming buffer is then reset.
- All connected users/processes automatically load the new full dump and continue receiving streaming updates.
Note for Windows users: To prevent the OS from garbage collecting shared memory when no handles are active, you can use the full_dump_size parameter to create a static full dump memory that lives as long as the creator process.