https://github.com/fcrozetta/moirai
moirai engine
https://github.com/fcrozetta/moirai
Last synced: 4 months ago
JSON representation
moirai engine
- Host: GitHub
- URL: https://github.com/fcrozetta/moirai
- Owner: fcrozetta
- License: mit
- Created: 2024-11-04T19:13:18.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-22T15:16:42.000Z (about 1 year ago)
- Last Synced: 2025-10-31T10:55:18.368Z (8 months ago)
- Language: Python
- Homepage:
- Size: 298 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# moirai-engine
[](https://pypi.org/project/moirai-engine)
[](https://pypi.org/project/moirai-engine)
-----
## Table of Contents
- [moirai-engine](#moirai-engine)
- [Table of Contents](#table-of-contents)
- [Installation](#installation)
- [Usage](#usage)
- [Basic Example](#basic-example)
- [Advanced Example](#advanced-example)
- [About](#about)
- [License](#license)
> **NOTE:** This doc is still in progress. for now it was generated by AI (sorry).
## Installation
```console
pip install moirai-engine
```
## Usage
### Basic Example
Here is a basic example of how to use the `moirai-engine` library to create and run a simple job:
```python
import time
from moirai_engine.core.engine import Engine
from moirai_engine.utils.samples import hello_world
# Create and start the engine
engine = Engine()
engine.start()
# Create a job using the hello_world sample
job = hello_world()
# Add the job to the engine
engine.add_job(job)
# Let the engine run for a while
time.sleep(5)
# Stop the engine
engine.stop()
```
### Advanced Example
Here is an advanced example that includes real-time notifications and job cancellation:
```python
import asyncio
from moirai_engine.core.engine import Engine
from moirai_engine.utils.samples import hello_world
# Create an async function
async def notification_listener(notification):
print(f"Received notification: {notification}")
async def main():
engine = Engine(max_workers=4, listener=notification_listener)
await engine.start()
# Add jobs to the engine
await engine.add_job(hello_world(), notification_listener)
# Let the engine run for a while
await asyncio.sleep(2)
await engine.stop()
if __name__ == "__main__":
asyncio.run(main())
```
## About
`moirai-engine` is the engine that powers [Ananke](https://github.com/fcrozetta/ananke), but it was planned to be used as a processing engine. This project is still in progress, and features like task registry and autodiscover are still in development.
## License
MIT License