How to use the cysystemd._daemon.sd_notify function in cysystemd

To help you get started, we’ve selected a few cysystemd 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 mosquito / cysystemd / cysystemd / daemon.py View on Github external
raise ValueError(
            "State %s should contain only constant value %r"
            % (state.name, state.constant),
            state.name,
            state.constant,
        )

    line = "%s=%s" % (
        state.name,
        state.constant if state.constant is not None else state.type(value),
    )

    log.debug("Send %r into systemd", line)

    try:
        return sd_notify(line, unset_environment)
    except Exception as e:
        if return_exceptions:
            log.error("%s", e)
            return e
        raise