removed streamer events

This commit is contained in:
Devaev Maxim 2018-06-27 23:33:45 +03:00
parent 3fefb0d519
commit 1a419cc52d
2 changed files with 0 additions and 15 deletions

View File

@ -75,7 +75,6 @@ class _Application:
self.__system_tasks.extend([ self.__system_tasks.extend([
self.__loop.create_task(self.__poll_dead_sockets()), self.__loop.create_task(self.__poll_dead_sockets()),
self.__loop.create_task(self.__poll_atx_leds()), self.__loop.create_task(self.__poll_atx_leds()),
self.__loop.create_task(self.__poll_streamer_events()),
]) ])
aiohttp.web.run_app( aiohttp.web.run_app(
@ -134,11 +133,6 @@ class _Application:
await self.__broadcast("EVENT atx_leds %d %d" % (self.__atx.get_leds())) await self.__broadcast("EVENT atx_leds %d %d" % (self.__atx.get_leds()))
await asyncio.sleep(self.__config["atx"]["leds"]["poll"]) await asyncio.sleep(self.__config["atx"]["leds"]["poll"])
@_system_task
async def __poll_streamer_events(self) -> None:
async for event in self.__streamer.events():
await self.__broadcast("EVENT %s" % (event))
async def __broadcast(self, msg: str) -> None: async def __broadcast(self, msg: str) -> None:
await asyncio.gather(*[ await asyncio.gather(*[
ws.send_str(msg) ws.send_str(msg)

View File

@ -2,7 +2,6 @@ import asyncio
import asyncio.subprocess import asyncio.subprocess
from typing import Dict from typing import Dict
from typing import AsyncIterator
from typing import Optional from typing import Optional
from contextlog import get_logger from contextlog import get_logger
@ -34,7 +33,6 @@ class Streamer: # pylint: disable=too-many-instance-attributes
self.__loop = loop self.__loop = loop
self.__lock = asyncio.Lock() self.__lock = asyncio.Lock()
self.__events_queue: asyncio.Queue = asyncio.Queue()
self.__proc_task: Optional[asyncio.Task] = None self.__proc_task: Optional[asyncio.Task] = None
def __set_output_pin(self, pin: int) -> int: def __set_output_pin(self, pin: int) -> int:
@ -42,10 +40,6 @@ class Streamer: # pylint: disable=too-many-instance-attributes
GPIO.output(pin, False) GPIO.output(pin, False)
return pin return pin
async def events(self) -> AsyncIterator[str]:
while True:
yield (await self.__events_queue.get())
async def start(self) -> None: async def start(self) -> None:
async with self.__lock: async with self.__lock:
get_logger().info("Starting mjpg_streamer ...") get_logger().info("Starting mjpg_streamer ...")
@ -61,7 +55,6 @@ class Streamer: # pylint: disable=too-many-instance-attributes
await asyncio.gather(self.__proc_task, return_exceptions=True) await asyncio.gather(self.__proc_task, return_exceptions=True)
await self.__set_hw_enabled(False) await self.__set_hw_enabled(False)
self.__proc_task = None self.__proc_task = None
await self.__events_queue.put("mjpg_streamer stopped")
async def __set_hw_enabled(self, enabled: bool) -> None: async def __set_hw_enabled(self, enabled: bool) -> None:
# This sequence is important for enable # This sequence is important for enable
@ -82,9 +75,7 @@ class Streamer: # pylint: disable=too-many-instance-attributes
stdout=asyncio.subprocess.PIPE, stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.STDOUT, stderr=asyncio.subprocess.STDOUT,
) )
logger.info("Started mjpg_streamer pid=%d: %s", proc.pid, self.__cmd) logger.info("Started mjpg_streamer pid=%d: %s", proc.pid, self.__cmd)
await self.__events_queue.put("mjpg_streamer started")
empty = 0 empty = 0
while proc.returncode is None: while proc.returncode is None: