Skip to content

Commit

Permalink
Log when tasks fail + bump proto requirement (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
keepingitneil authored Dec 14, 2023
1 parent cc1d4c4 commit 5d2bff6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
13 changes: 13 additions & 0 deletions livekit-rtc/livekit/rtc/_utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
import asyncio
import logging
from collections import deque
import ctypes
from typing import Callable, Generic, List, TypeVar

logger = logging.getLogger("livekit")


def task_done_logger(task: asyncio.Task) -> None:
if task.cancelled():
logger.info("task cancelled: %s", task)
return

if task.exception():
logger.error("task exception: %s", task, exc_info=task.exception())
return


def get_address(data: memoryview) -> int:
"""Get the address of a buffer using ctypes"""
Expand Down
3 changes: 2 additions & 1 deletion livekit-rtc/livekit/rtc/audio_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from ._ffi_client import FfiHandle, ffi_client
from ._proto import audio_frame_pb2 as proto_audio_frame
from ._proto import ffi_pb2 as proto_ffi
from ._utils import RingQueue
from ._utils import RingQueue, task_done_logger
from .audio_frame import AudioFrame
from .track import Track

Expand Down Expand Up @@ -46,6 +46,7 @@ def __init__(
self._info = stream_info

self._task = self._loop.create_task(self._run())
self._task.add_done_callback(task_done_logger)

def __del__(self) -> None:
ffi_client.queue.unsubscribe(self._ffi_queue)
Expand Down
3 changes: 2 additions & 1 deletion livekit-rtc/livekit/rtc/video_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from ._ffi_client import FfiHandle, ffi_client
from ._proto import ffi_pb2 as proto_ffi
from ._proto import video_frame_pb2 as proto_video_frame
from ._utils import RingQueue
from ._utils import RingQueue, task_done_logger
from .track import Track
from .video_frame import VideoFrame, VideoFrameBuffer

Expand All @@ -45,6 +45,7 @@ def __init__(
self._ffi_handle = FfiHandle(stream_info.handle.id)
self._info = stream_info.info
self._task = self._loop.create_task(self._run())
self._task.add_done_callback(task_done_logger)

def __del__(self) -> None:
ffi_client.queue.unsubscribe(self._ffi_queue)
Expand Down
2 changes: 1 addition & 1 deletion livekit-rtc/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def run(self):
license="Apache-2.0",
packages=setuptools.find_namespace_packages(include=["livekit.*"]),
python_requires=">=3.9.0",
install_requires=["protobuf>=3.1.0", "types-protobuf>=3.1.0"],
install_requires=["protobuf>=4", "types-protobuf>=4"],
package_data={
"livekit.rtc": ["resources/*", "_proto/*.py", "py.typed", "*.pyi", "**/*.pyi"],
},
Expand Down

0 comments on commit 5d2bff6

Please sign in to comment.