Warning
This project is a work in progress; be patient or feel free to contribute.
sharedbox keeps records in shared memory. Each box is one named segment, and every process that opens it reads and writes the same fields.
It is recommended to install sharedbox in a virtual environment; for example using uv:
uv venv --python 3.11
.venv\Scripts\activate
uv pip install sharedboximport multiprocessing as mp
from typing import Annotated
from sharedbox import Capacity, SharedBox
class Motor(SharedBox):
position: int
enabled: bool
label: Annotated[str, Capacity(32)]
def worker() -> None:
motor = Motor.attach() # finds the box by its class
motor.position = 10
motor.close()
if __name__ == "__main__":
with Motor(1, False, "x-axis") as motor:
motor.events.position.connect(lambda new, old: print(old, "->", new))
child = mp.Process(target=worker)
child.start()
child.join() # prints: 1 -> 10
Motor.unlink()The documentation site has a tutorial, how-to guides, explanations of how a box works, and the API reference.
C++ and C code can take a box from Python or open one by name; see the C and C++ guides.
Licensed under Apache 2.0