Skip to main content

format_sse_event

Build SSE wire-format bytes from pre-serialized data.

The result always ends with \n\n (the event terminator).

def format_sse_event(
data_str: str | None = None,
event: str | None = None,
id: str | None = None,
retry: int | None = None,
comment: str | None = None
) - > bytes

Build SSE wire-format bytes from pre-serialized data. The result always ends with \n\n (the event terminator).

Parameters

NameTypeDescription
data_str`strNone` = None
event`strNone` = None
id`strNone` = None
retry`intNone` = None
comment`strNone` = None

Returns

TypeDescription
bytesThe UTF-8 encoded byte string formatted according to the Server-Sent Events specification, ready for transmission.