Skip to main content

"A (micro)python library for pub-sub messaging for (u)asyncio apps"

Project description

ubub

ubub

A (micro)python library for pub-sub messaging for (u)asyncio apps

Simple demo:

from ubub import Ub

try:
    import uasyncio as asyncio
except ImportError:
    import asyncio

ub = Ub()

async def sender(msg="Ahoj!", delay=1):
    while True:
        ub.pub("topic", msg)
        await asyncio.sleep(delay)


async def receiver():
    while True:
        msg = await ub.sub("topic")
        print("Message:", msg)


async def main():
    # Subscribers
    asyncio.create_task(receiver())

    # Senders
    asyncio.create_task(sender())
    asyncio.create_task(sender("Ciao", 0.5))

    while True:
        await asyncio.sleep(1)


if __name__ == "__main__":
    asyncio.run(main())

Contribution notes

Design

Logo - Font Assistant Extra Light 200

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

ubub-0.0.1.dev0.tar.gz (2.7 kB view details)

Uploaded Source

File details

Details for the file ubub-0.0.1.dev0.tar.gz.

File metadata

  • Download URL: ubub-0.0.1.dev0.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

File hashes

Hashes for ubub-0.0.1.dev0.tar.gz
Algorithm Hash digest
SHA256 d8f228632f9671e140e0b9b885e2e0c96ca2014f1010c4e0f46165f129666a13
MD5 c390868d8590c1a36d389230e48b3e08
BLAKE2b-256 9c04e26ce4c20e03ff251689b828d9759bf640c666dc872e46822821c1cc33ab

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page