Skip to main content

AsyncEv: asynchronous event objects

PyPI - Python VersionPyPI - Types

AsyncEv leverages asyncio to create events that can be subscribed to and waited for.

Installation

pip install asyncev

Usage

import asyncio
import asyncev
from dataclasses import dataclass

# Create an event
@dataclass
class MyEvent(asyncev.Event):
    value: str

# Create a listener
async def on_myevent(ev: MyEvent):
    print(f"Got a MyEvent with the value {ev.value}!")

# also works for methods, with binds possible at init time.
class Listener:
    def __init__(self, name: str):
        self.name = name
        asyncev.bind(MyEvent, self.on_myevent)
    async def on_myevent(self, ev: MyEvent):
        print(f"{self.name} got a MyEvent with the value {ev.value}!")

asyncev.bind(MyEvent, on_myevent)


# Emit event (requires a running asyncio event loop)
async def main():
    jeff = Listener("Jeff")
    asyncev.emit(MyEvent(value="hello"))
    await asyncio.sleep(.1)

    del jeff  # cleanup of event listeners is automatic
    asyncev.emit(MyEvent("goodbye"))
    await asyncio.sleep(.1)
    
asyncio.run(main())

Development

Recommended tooling is uv. install it with pip.

Building

$ uv build

Testing

$ uv run tox

Metadata

Release files for asyncev 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for asyncev 1.0.2
File Size Uploaded
asyncev-1.0.2.tar.gz 18.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for asyncev 1.0.2
File Interpreter ABI Platform
asyncev-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 23.6 kB

Release files / asyncev-1.0.2.tar.gz

Download URL asyncev-1.0.2.tar.gz
Size 18.6 kB
Tags Source
SHA-256 checksum
How to use checksums
5f866f56f3b22e4739df06dd50d0f46ed94d61924a0668841b0b4481ce1f1392
BLAKE2b-256 checksum
How to use checksums
be5d0cda8079dd83203587176733a8528acab529f335b16ee20caade78e6613b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.21

Release files / asyncev-1.0.2-py3-none-any.whl

Download URL asyncev-1.0.2-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8c5829327b024c154af9443cdfb0dd2f6eeabb105754be43250b5b719eb442b6
BLAKE2b-256 checksum
How to use checksums
e35e15992a341ebebd97bfb33507158a75a2414333f69c3af60ed57352a8ea24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.21

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0.1

2 release files

1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page