Callbacker
Callbacker is a lightweight and flexible callback library for both synchronous and asynchronous Python programming. It provides a simple yet powerful way to implement event-driven programming patterns in Python.
Features
- Support for both synchronous and asynchronous callbacks
- Decorator-based event registration
- Type-safe event handling
- Easy to integrate with existing codebases
- Minimal dependencies (only requires
frozenlist) - Python 3.11+ support
- Thread-safe event dispatching
Installation
You can install Callbacker using PDM:
pip callbacker
Quick Start
Here's a simple example of how to use Callbacker:
from callbacker.callback import EventWrapper
# Create an event
custom_event = EventWrapper()
# Register a callback using decorator syntax
@custom_event
async def on_event(data):
print(f"Received event with data: {data}")
# Trigger the event asynchronously
await custom_event.aio_send("Hello, World!")
Advanced Usage
Class-based Events
from callbacker.callback import event, contextevent
class MyClass:
@event
async def on_data(self, data):
"""This is a regular event"""
print(f"Received data: {data}")
@contextevent
async def on_update(self, context, data):
"""This event includes the class instance as context"""
print(f"Update from {context} with data: {data}")
Synchronous Callbacks
from callbacker.callback import EventWrapper
event = EventWrapper()
@event
def sync_handler(data):
print(f"Handling {data} synchronously")
# Trigger synchronously
event.send("test data")
Documentation
For more detailed documentation and examples, please visit the documentation page.
Contributing
Contributions are welcome! Please read our Contributing Guidelines for details on how to submit pull requests, report issues, and contribute to the project.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Metadata
Release files for callbacker 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| callbacker-0.1.0.tar.gz | 4.2 kB | Without provenance | Details for callbacker-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| callbacker-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for callbacker-0.1.0-py3-none-any.whl |
Total release size: 9.5 kB
Release files / callbacker-0.1.0.tar.gz
| Download URL | callbacker-0.1.0.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
70e2ec97e53982e82eaa80efcf3c00e5678f820db713db1e786107239867ac34
|
|
BLAKE2b-256 checksum How to use checksums |
d0a56f6bc97a1a05756c9a63697afb2d44a6bd0a656f9892a0dd6d191cbc53a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.22.1 CPython/3.13.1 Darwin/24.2.0
|
Release files / callbacker-0.1.0-py3-none-any.whl
| Download URL | callbacker-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
80fd423cf837d4c0a38badafcb023da23c02b5e55070d610e6a85f312b37d0a2
|
|
BLAKE2b-256 checksum How to use checksums |
0d6dcbaed153665a0e295e50d9e10c933be15656a03f92884bd2f0bca6804d00
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.22.1 CPython/3.13.1 Darwin/24.2.0
|
Security for callbacker 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.