How to use the cent.CentException function in cent

To help you get started, we’ve selected a few cent examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github synw / django-instant / instant / producers.py View on Github external
def publish_py(message, channel=None, event_class="default", data=None,
               site=SITE_NAME, target=None):
    cent_url = CENTRIFUGO_HOST + ":" + str(CENTRIFUGO_PORT)
    client = Client(cent_url, SECRET_KEY, timeout=1)
    channel = _get_channel(channel, target)
    if data is None:
        data = {}
    payload = {"message": message, "channel": channel,
               'event_class': event_class, "data": data, "site": site}
    err = None
    try:
        client.publish(channel, payload)
    except CentException as e:
        err = str(e)
    if event_class.lower() == "debug":
        print("[DEBUG] ", str(json.dumps(payload)))
    return err

cent

Python library to communicate with Centrifugo v5 server HTTP API

Apache-2.0
Latest version published 10 months ago

Package Health Score

71 / 100
Full package analysis