From 8b5eb82497a08531557c78595a327f867f6b39f2 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Tue, 30 May 2023 11:06:48 +0200 Subject: [PATCH] Camera stream writer fixes. - The readiness condition should be `multiprocessing.Condition`, not `threading.Condition` - in most of the cases it will be checked in a multiprocess environment. - Fixed parameter name for `write`. --- platypush/plugins/camera/model/writer/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/platypush/plugins/camera/model/writer/__init__.py b/platypush/plugins/camera/model/writer/__init__.py index 0fb859255..1113dcf10 100644 --- a/platypush/plugins/camera/model/writer/__init__.py +++ b/platypush/plugins/camera/model/writer/__init__.py @@ -1,7 +1,7 @@ import io import logging +import multiprocessing import os -import threading import time from abc import ABC, abstractmethod @@ -26,11 +26,11 @@ class VideoWriter(ABC): self.closed = False @abstractmethod - def write(self, img: Image): + def write(self, image: Image): """ Write an image to the channel. - :param img: PIL Image instance. + :param image: PIL Image instance. """ raise NotImplementedError() @@ -76,7 +76,7 @@ class StreamWriter(VideoWriter, ABC): self.frame: Optional[bytes] = None self.frame_time: Optional[float] = None self.buffer = io.BytesIO() - self.ready = threading.Condition() + self.ready = multiprocessing.Condition() self.sock = sock def write(self, image: Image):