forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlive_content.py
More file actions
29 lines (22 loc) · 991 Bytes
/
Copy pathlive_content.py
File metadata and controls
29 lines (22 loc) · 991 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""Recover a fenced live-content write by moving once to a fresh generation."""
from __future__ import annotations
from collections.abc import Awaitable, Callable
from typing import TypeVar
ContentWrite = TypeVar('ContentWrite')
async def retry_fenced_live_content_once(
*,
write_current: Callable[[], ContentWrite | None],
rollover: Callable[[], Awaitable[None]],
write_fresh: Callable[[], ContentWrite | None],
) -> tuple[ContentWrite | None, bool]:
"""Write content once, rolling over only when cleanup fenced that write.
A missing parent is a terminal durable outcome for its recording session;
recreating that parent would violate the lifecycle fence. The caller must
instead open a fresh session/conversation generation and replay its still
buffered content exactly once.
"""
current_result = write_current()
if current_result is not None:
return current_result, False
await rollover()
return write_fresh(), True