Python multi-task communication library. Used by OctoBot project.

Clone this repo:
  1. 597f2d1 [CI] Fix travis deploy by Herklos · 2 years, 2 months ago master 2.0.1
  2. 4574b4e [README] Update badge by Herklos · 2 years, 2 months ago
  3. a15df55 [Project] Migrate to Async-Channel by Herklos · 2 years, 2 months ago
  4. 6da935e [Version] v2.0.1 by Herklos · 2 years, 2 months ago
  5. ab4f19b [ImportsMigration] Migrate imports by Herklos · 2 years, 2 months ago 2.0.0

Async-Channel 2.0.1

Codacy Badge PyPI Build Status Build Status Build Status Coverage Status Doc Status Code style: black

Python multi-task communication library. Used by OctoBot project.

Installation

With python3 : pip install async-channel

Usage

Example

import async_channel.consumer as consumer
import async_channel.producer as producer
import async_channel.channels as channels
import async_channel.util as util

class AwesomeProducer(producer.Producer):
    pass

class AwesomeConsumer(consumer.Consumer):
    pass

class AwesomeChannel(channels.Channel):
    PRODUCER_CLASS = AwesomeProducer
    CONSUMER_CLASS = AwesomeConsumer

async def callback(data):
    print("Consumer called !")
    print("Received : " + data)

# Creates the channel
await util.create_channel_instance(AwesomeChannel, channels.Channels)

# Add a new consumer to the channel
await channels.Channels.get_chan("Awesome").new_consumer(callback)

# Creates a producer that send data to the consumer through the channel
producer = AwesomeProducer(channels.Channels.get_chan("Awesome"))
await producer.run()
await producer.send("test")

# Stops the channel with all its producers and consumers
# await channels.Channels.get_chan("Awesome").stop()

Developer documentation

On readthedocs.io