Skip to main content
This example keeps a Rust creator alive while a Python process opens the same region. Run it from a repository checkout after following the installation guide.

Start the writer

In the first terminal:
The program creates a one-page data area, writes the four bytes ZINC, and sends a notification. It prints ready and waits for a line on standard input. Leave it running while you start the reader.

Read from Python

In a second terminal, from the repository root:
Then run:
The reader prints ZINC. It consumes the notification before reading, even though the writer sent it before the reader opened the region. Press Enter in the writer’s terminal to close the creator and unlink the name. Existing mappings remain valid until their handles and retained views close.

What happened

The creator used shm_open, ftruncate, and mmap to create a shared mapping. Python opened the same backing pages through the C ABI. Its buffer view accesses those bytes without a transfer through a socket or a serialization step. Data starts after the first header page. The writer uses the system page size, so this example works with both 4096-byte and 16384-byte pages. For repeated updates, add an acknowledgement before the writer overwrites data that a reader may still be using. See notify and wait, data access, and the adapter references.