Skip to main content

A way to create shared dataclasses in python for multiprocessing and multi threading real time applications

Project description

DataAnchor

DataAnchor is a Python library that enables seamless shared memory synchronization for Python dataclasses.

It provides a thread-safe and process-safe mechanism to share data between processes and threads, making it ideal for lightweight Inter-Process Communication (IPC) scenarios. It's built to be simple to use: just inherit the DataAnchor class into your dataclass, and its attributes will automatically be shared across processes.

You can also customize how your data is serialized and deserialized—just ensure the deserialization results in a dictionary matching the class's attributes.

This library was born out of a personal need to solve the critical problem of sharing data between processes and threads in a way that minimizes complexity and avoids common headaches. I hope it can help you too!

While I'm currently using DataAnchor for distributed systems within the same program, I'm actively working on extending its capabilities to support communication across different programs and even networks.

The larger vision is to create a simple PubSub system using shared_memory as the transport for sharing data seamlessly across programs and machines.


Key Features

  • Lightweight Shared Memory: Use Python's multiprocessing.shared_memory to share data across processes with minimal overhead.

  • Thread and Process Safety: Prevent race conditions with semaphores, ensuring synchronized reads and writes.

  • Dataclass Integration: Enhance Python dataclasses with shared memory capabilities by inheriting from DataAnchor.

  • Custom Serialization: Customize how your data is serialized and deserialized for flexible and efficient IPC.

  • Singleton Design: Each shared dataclass instance uses a single shared memory region, ensuring consistent and synchronized access.


Installation

Install the library using pip:

pip install data-anchor

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

data_anchor_py-0.0.23.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

data_anchor_py-0.0.23-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file data_anchor_py-0.0.23.tar.gz.

File metadata

  • Download URL: data_anchor_py-0.0.23.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for data_anchor_py-0.0.23.tar.gz
Algorithm Hash digest
SHA256 e293ed660fbdeaca9c11387dd39c36339c110b55ef9514d5cc8d9593e5dd602a
MD5 4b7c75c6b8182b5017d3ad163cb1015e
BLAKE2b-256 494adcb78bbb0e65d1b0ed507ab11fae4ae8ba8ebc6857bcf95ffe2add8c872e

See more details on using hashes here.

File details

Details for the file data_anchor_py-0.0.23-py3-none-any.whl.

File metadata

File hashes

Hashes for data_anchor_py-0.0.23-py3-none-any.whl
Algorithm Hash digest
SHA256 a76462d3f2e2efc332ad0512969ebc47e27f24c4290111d90cf78de226932cd8
MD5 1ee02c5663c730842e2e5dbb62490f5f
BLAKE2b-256 855d9ae7425d2bf29dfc8130bf390033e0044e6722ec408ab498f44905093845

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page