Skip to main content

Chronous

py_ver issues

pypi_ver pypi_license pypi_package pypi_status

discord

Chronous is a asynchronous python library designed to make asynchronous event-driven architectures on discord.py

[Example]

import asyncio
from typing import NoReturn
import datetime
from chronous.Architecture import BaseArchitecture
from chronous.events import EventContext, Setup, Init, Start, Close

class SampleArchitecture(BaseArchitecture):

  def __init__(self) -> None:
    super(SampleArchitecture, self).__init__(name="sample")

    # Registering events
    self.register_event(event=Setup())
    self.register_event(event=Init())
    self.register_event(event=Start())
    self.register_event(event=Close())

  def run(self) -> None:
    # Registering default lifecycle events
    # Start process.
    print("Starting process...")
    asyncio.run(self.process())

  async def process(self) -> NoReturn:
    await self.dispatch("setup")
    await self.dispatch("init")
    print('='*20)
    await self.dispatch("start", datetime.datetime.now())
    index: int = 0
    while index < 10:
      print("Looping!")
      index += 1
    await self.dispatch("close")
    print('='*20)


sample = SampleArchitecture()

# Multiple listener sample
@sample.listen()
async def setup(ec: EventContext):
  print("{e.name} phase - listener 1".format(e=ec.event))


@sample.listen()
async def setup(ec: EventContext):
  print("{e.name} phase - listener 2".format(e=ec.event))


# EventContext  sample
@sample.listen()
async def init(ec: EventContext):
  print("Initialization phase")
  print("Event : {e}".format(e=ec.event))


# Additional arguments sample
@sample.listen()
async def start(ec: EventContext, time: datetime):
  print("Starting process...")
  print("Starting at : {time}".format(time=time))


# Exception sample
@sample.listen()
async def close(ec: EventContext):
  print("Closing process...")
  print(f"Make an error : {1/0}")

sample.run()

Release files for chronous 1.2.1

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

Built distribution (wheel)

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

Release files / chronous-1.2.1-py3-none-any.whl

Download URL chronous-1.2.1-py3-none-any.whl
Size 8.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4118cc0fa5f4a0f1baee23dfe6b39bf58cc6e217500d014a2ca66c3640462b88
BLAKE2b-256 checksum
How to use checksums
4c983f207663193ec82c8c6c83b7dc2af7ecc6c4e7ba64e743807a4d67e31235
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
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