Lightweight library for building concurrent systems.
Project description
rosny is a lightweight library for building concurrent systems.
Installation
Tested on:
- Linux
- Python >= 3.8
From pip:
pip install rosny
From source:
pip install git+https://github.com/lRomul/rosny.git@master
Example
from multiprocessing import Queue
from rosny import ThreadNode, ProcessNode, ComposeNode
class SenderNode(ThreadNode): # using threading.Thread
def __init__(self, queue: Queue):
super().__init__(loop_rate=30)
self.queue = queue
self.count = 0
# run the method in a loop in a separate thread
def work(self):
self.queue.put(self.count)
self.logger.info(f'put {self.count}')
self.count += 1
class ReceiverNode(ProcessNode): # using multiprocessing.Process
def __init__(self, queue: Queue):
super().__init__()
self.queue = queue
# run the method in a loop in a separate process
def work(self):
value = self.queue.get(timeout=1)
self.logger.info(f'get {value}')
class MainNode(ComposeNode): # merging several nodes
def __init__(self):
super().__init__()
queue = Queue()
self.sender = SenderNode(queue)
self.receiver = ReceiverNode(queue)
if __name__ == "__main__":
node = MainNode()
node.start()
node.wait(5)
node.stop()
node.join()
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
rosny-0.1.0.tar.gz
(12.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
rosny-0.1.0-py3-none-any.whl
(10.2 kB
view details)
File details
Details for the file rosny-0.1.0.tar.gz.
File metadata
- Download URL: rosny-0.1.0.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4cf2513657cbf9bfb8f75d627d00c87a5353ecf73b3acf6d5c4937ec179ef68
|
|
| MD5 |
4b3d34497ec2c4bcee630ba2fb40e062
|
|
| BLAKE2b-256 |
783a930dad8e27e1d535fc195df3bad3b9128a83e8cf7be2e632b54eff2a217a
|
File details
Details for the file rosny-0.1.0-py3-none-any.whl.
File metadata
- Download URL: rosny-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6af6acbb2c824604f29100635cc779c26e4da3468c7739fdb61bac74ea50f67c
|
|
| MD5 |
395209c89462a4722101b736ddc3ceaa
|
|
| BLAKE2b-256 |
3eb6f913ec2753083b484734b838d0f27afdd50205b4ec23ff59852908e2ef7f
|