openjev / code /serving /service_notify.py
AlexWortega's picture
Add image Decisions serving and explicit option probabilities
26de23c verified
Raw History Blame Contribute Delete
390 Bytes
"""Small dependency-free systemd notification helper."""
import os
import socket
def notify(message):
address = os.environ.get("NOTIFY_SOCKET")
if not address:
return
if address.startswith("@"):
address = "\0" + address[1:]
with socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM) as sock:
sock.connect(address)
sock.sendall(message.encode())