Skip to main content

Async python for Event-Driven applications

Project description

AsyncED


PyPI version shields.io PyPI pyversions PyPI license


Async python for Event-Driven applications

Installation

pip install asynced

High-level API

Coming soon...

Low-level API

Promise

Inspired by (but not a clone of) Javascript promises, asynced.Promise is a thin wrapper around any coroutine.

Like asyncio.Task, when a promise is created, the wrapped coroutine will run in the background, and can be awaited to get the result or exception. In addition, a Promise can be "chained" with sync or async functions, producing another Promise.

Example:

import asyncio
from asynced import Promise


async def formulate_ultimate_question() -> str:
    await asyncio.sleep(0.25)
    return (
        'What is The Answer to the Ultimate Question of Life, the Universe, '
        'and Everything?'
    )


async def compute_answer(question: str):
    await asyncio.sleep(0.75)
    return (len(question) >> 1) + 1


async def amain():
    answer = await Promise(formulate_ultimate_question()).then(compute_answer)
    print(answer)


asyncio.run(amain())

Perpetual

Where asyncio futures are the bridge between low-level events and a coroutines, perpetuals are the bridge between event streams and async iterators.

In it's essence, a perpetual is an asyncio.Future that can have its result (or exception) set multiple times, at least until it is stopped. Besides a perpetual being awaitable just like a future, it is an async iterator as well.

ensure_future

Wrap an async iterable in a perpetual, and automatically starts iterating.

See perpetual_drumkit.py for an example.

~

More docs and examples coming soon...

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

asynced-0.2.0.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

asynced-0.2.0-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file asynced-0.2.0.tar.gz.

File metadata

  • Download URL: asynced-0.2.0.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.10.3 Linux/5.13.0-35-generic

File hashes

Hashes for asynced-0.2.0.tar.gz
Algorithm Hash digest
SHA256 49f2f103c9563f80b2c39c773289cf52d32f78ab7cfa67a3f5bf04606f44111d
MD5 eefe4f5e0ccdd6a7b11f4be2e1c9dae9
BLAKE2b-256 23d51f22a3e582fb013ae3dd3e9418cd903df88063045479d980c12959229283

See more details on using hashes here.

File details

Details for the file asynced-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: asynced-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.10.3 Linux/5.13.0-35-generic

File hashes

Hashes for asynced-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2ccc136b307b71b88bbe839ffa11791c2092028529bc0dd11ff61ea08887c638
MD5 69dc6c828fbf05fa592eac2bbb203755
BLAKE2b-256 d6c0d33234c72e7015a71af3047f8b66fc83ec1ee8d6fb183b1b135cd2cafbee

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