Skip to main content

omq

Omq is a IPC that uses Nanomsg under the hood. It likes MQTT in some degree.

Concept

nanomsg is a socket library that provides several common communication patterns. It aims to make the networking layer fast, scalable, and easy to use. Implemented in C, it works on a wide range of operating systems with no further dependencies. But its sub-pub mode is not very good for us to use. So, omq bornd. Through omq, you can easily publish and subscribe message like MQTT.

Installation

pip install git+https://cloud.orca-tech.cn:9091/rty813/omq.git

Omq requires python 3.6+ and CMake 3.13+

Usage

Bus

# node1.py
import omq

with omq.Bus() as node:
    node.publish('test', 'hello world')
# node2.py
import omq

def on_message(topic, payload):
    print(f'{topic} - {payload}')

with omq.Bus() as node:
    node.on_message = on_message
    node.subscribe(['test', 'test/#'])
    node.loop_forever()

REQ/REP

# rep.py
import omq

def handler(topic, payload):
    print(topic, payload)
    # Handle data...
    return 'ok'

with omq.Rep(omq.Addr.MAIN, handler) as node:
    node.loop_forever()
# req.py
import omq

res = omq.req(omq.Addr.MAIN, 'test', 'req data')
print(res)  # ok

Supernode/Slavenode

# Supernode.py
import omq

count = 0
node = omq.SuperNode()

def on_message(slave_id, payload):
    global count
    count += 1
    if count % 3 == 0:
        print(f'send: {slave_id}')
        node.publish(slave_id, 'Recv')

    print(f'recv: {slave_id} - {payload}')

node.on_message = on_message
node.loop_forever()
# Slave.py
import omq
import time

node = omq.SlaveNode('node1', '127.0.0.1')

def on_message(payload):
    print('recv: ' + payload)

node.on_message = on_message

node.loop_start()

while True:
    try:
        node.publish({'a': time.time(), 'b': 2})
        time.sleep(1)
    except:
        node.close()
        break

Release files for omq 0.5.5

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

Source distribution (sdist)

Source distribution for omq 0.5.5
File Size Uploaded
omq-0.5.5.tar.gz 5.1 kB Details

Built distribution (wheel)

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

Total release size: 11.2 kB

Release files / omq-0.5.5.tar.gz

Download URL omq-0.5.5.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
de548acd256a74646e5271749f2c3a82d6f2cc569df805265b32edade8aa3cc4
BLAKE2b-256 checksum
How to use checksums
fe9af6702104788eb5215841ae39ae2c2ea3e07ed3f4e825a22ebd9aae17616c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.2

Release files / omq-0.5.5-py3-none-any.whl

Download URL omq-0.5.5-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e1eecaa3b67894a58db731c46f1bcd8922aebff313983d72b3b5bc287f28edcf
BLAKE2b-256 checksum
How to use checksums
41da7f0cd24c4e9abc4990697e4fa05e7e2da990442a06cbd0cb36ce1bc124ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.2

Release history Release notifications | RSS feed

This release

0.5.5 This release

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

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