~naglis/aio_mpv_ipc

297fbd02311cc814cdcf0820f3d7cb1664f53f63 — Naglis Jonaitis 10 months ago d2855df
Introduce event_queue_timeout
1 files changed, 15 insertions(+), 1 deletions(-)

M aio_mpv_ipc/_client.py
M aio_mpv_ipc/_client.py => aio_mpv_ipc/_client.py +15 -1
@@ 77,6 77,7 @@ class MpvClient:
        *,
        max_connect_attempts: int = 5,
        connect_sleep_timeout: float = 0.5,
        event_queue_timeout: float = 1.0,
        json_loads=_default_json_loads,
        json_dumps=_default_json_dumps,
    ) -> None:


@@ 84,6 85,7 @@ class MpvClient:
        self._reader, self._writer = None, None
        self._max_connect_attempts = max_connect_attempts
        self._connect_sleep_timeout = connect_sleep_timeout
        self._event_queue_timeout = event_queue_timeout
        self._json_loads, self._json_dumps = json_loads, json_dumps
        self._poll_task = None



@@ 163,7 165,19 @@ class MpvClient:
                # This is an event notification, notify subscribers (if any).
                if event_name in self._event_subscribers:
                    for queue in self._event_subscribers[event_name]:
                        await queue.put(response)
                        try:
                            await asyncio.wait_for(
                                queue.put(response), timeout=self._event_queue_timeout
                            )
                        except asyncio.TimeoutError:
                            logger.warning(
                                'Timeout while adding event "%s" response "%s" '
                                "to queue: %s. The event will be dropped",
                                event_name,
                                response,
                                queue,
                            )

            else:
                status = response.get("error")
                is_error = status and status != "success"