await self.players.setup()
await self.web.setup()
await self.http_streamer.setup()
- # temp code to chase memory leak
- import subprocess
- subprocess.call("pip install mem_top", shell=True)
- self.event_loop.create_task(self.print_memory())
def handle_exception(self, loop, context):
''' global exception handler '''
async def remove_event_listener(self, cb_id):
''' remove callback from our event listeners '''
- self.event_listeners.pop(cb_id, None)
-
- @run_periodic(60)
- # TEMP: Check for any memory leaks
- async def print_memory(self):
- from mem_top import mem_top
- print(mem_top())
+ self.event_listeners.pop(cb_id, None)
\ No newline at end of file
while self.mass.event_loop.is_running():
try:
protocol = 'wss' if self._use_ssl else 'ws'
- async with self.http_session.ws_connect('%s://%s/api/websocket' % (protocol, self._host)) as ws:
+ async with self.http_session.ws_connect('%s://%s/api/websocket' % (protocol, self._host), verify_ssl=False) as ws:
async def send_msg(msg):
''' callback to send message to the websockets client'''
def fill_buffer():
chunk_size = int(sample_rate * 4 * 2)
- while sox_proc.returncode == None:
+ while True:
chunk = sox_proc.stdout.read(chunk_size)
+ if not chunk:
+ break
if chunk and not cancelled.is_set():
asyncio.run_coroutine_threadsafe(
buffer.put(chunk), self.mass.event_loop)
data = process.stdout.read(chunksize)
if not data:
# no more data
- # yield (empty) chunk as lust chunk
+ # yield leftover data in buffer as last chunk
yield (True, buf)
bytes_sent += len(buf)
del buf