Skip to main content

A shared memory event system for Python

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

mvent

by BRAHMAI

A Python package that provides an event-driven interface for shared memory communication between processes.

Features

  • Shared memory communication between processes
  • Event-driven architecture using decorators
  • TTL support for temporary data
  • Automatic cleanup of expired data
  • Thread-safe operations

Installation

pip install mvent

Quick Start

from mvent import MemoryEventHandler
import time

# Create a memory event handler
memory_events = MemoryEventHandler("my_pool")

# Define an event handler using decorator
@memory_events.on("user_data")
def handle_user_update(new_value):
    print(f"User data updated: {new_value}")

# Emit an event
memory_events.emit("user_data", {"name": "John", "age": 30})

# Emit with TTL (expires after 5 seconds)
memory_events.emit("user_data", {"name": "Jane"}, ttl=5.0)

# Keep the program running
time.sleep(6)
memory_events.cleanup()

How It Works

The package uses memory-mapped files for shared memory communication between processes. When a process updates a value in shared memory, all registered event handlers in other processes are automatically notified and executed.

Advanced Usage

Multiple Handlers

# Multiple handlers for the same event
@memory_events.on("user_data")
def log_user_update(new_value):
    print(f"Logging: {new_value}")

@memory_events.on("user_data")
def process_user_update(new_value):
    # Process the data
    pass

Using TTL

# Data expires after 60 seconds
memory_events.emit("temporary_data", "This will expire", ttl=60.0)

License

MIT License

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

mvent-0.1.0a0.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

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

mvent-0.1.0a0-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file mvent-0.1.0a0.tar.gz.

File metadata

  • Download URL: mvent-0.1.0a0.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for mvent-0.1.0a0.tar.gz
Algorithm Hash digest
SHA256 76c507c5b33fa909869d4101d4848f8043374404b283a3b85ef3eaa9e204639c
MD5 b56c94bd8a443f345837094943bd91a0
BLAKE2b-256 ba9c4261249c3561cf0331e37bb6d729631739c8b3ff16cd380fcb8243a6c7b8

See more details on using hashes here.

File details

Details for the file mvent-0.1.0a0-py3-none-any.whl.

File metadata

  • Download URL: mvent-0.1.0a0-py3-none-any.whl
  • Upload date:
  • Size: 3.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for mvent-0.1.0a0-py3-none-any.whl
Algorithm Hash digest
SHA256 240708bbdcf3b5d4863d47403dfff37507c1b5400e66cd43221fdbf0083a86f4
MD5 39ddc196650eae4535c141fcf7abd9a5
BLAKE2b-256 ccf233139ce48b574b88134561a57af1ea6d05e9ff275cb004156a2909742038

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