Fix queing of restart
This commit is contained in:
parent
46299d2dac
commit
2a712fb7e1
1 changed files with 11 additions and 3 deletions
|
@ -320,14 +320,22 @@ class HugveyState(object):
|
||||||
self.logger.critical("No event queue to put {}".format(msg))
|
self.logger.critical("No event queue to put {}".format(msg))
|
||||||
else:
|
else:
|
||||||
# Allow for both the Hugvey Command, or the Story handle the event.
|
# Allow for both the Hugvey Command, or the Story handle the event.
|
||||||
self.eventQueue.put_nowait(msg)
|
self.loop.call_soon_threadsafe(self._queueEvent, msg)
|
||||||
self.story.events.append(msg)
|
|
||||||
|
|
||||||
|
def _queueEvent(self, msg):
|
||||||
|
self.logger.debug(f"Queue event in hugvey loop: {msg}")
|
||||||
|
self.eventQueue.put_nowait(msg)
|
||||||
|
self.story.events.append(msg)
|
||||||
|
|
||||||
async def handleEvents(self):
|
async def handleEvents(self):
|
||||||
self.eventQueue = asyncio.Queue() # start event queue here, to avoid loop issues
|
self.eventQueue = asyncio.Queue() # start event queue here, to avoid loop issues
|
||||||
while self.command.isRunning.is_set():
|
while self.command.isRunning.is_set():
|
||||||
event = await self.eventQueue.get()
|
event = await self.eventQueue.get()
|
||||||
self.logger.info("Received: {}".format(event))
|
self.logger.info("Received: {}".format(event))
|
||||||
|
|
||||||
|
if event['event'] == 'connection' and not self.isRunning.is_set():
|
||||||
|
self.restart()
|
||||||
|
|
||||||
if event['event'] == 'language':
|
if event['event'] == 'language':
|
||||||
self.setLanguage(event['code'])
|
self.setLanguage(event['code'])
|
||||||
|
@ -434,7 +442,7 @@ class HugveyState(object):
|
||||||
self.logger.info("Start audio stream")
|
self.logger.info("Start audio stream")
|
||||||
|
|
||||||
while self.notShuttingDown:
|
while self.notShuttingDown:
|
||||||
# self.isRunning.wait()
|
await self.isRunning.wait()
|
||||||
|
|
||||||
self.logger.info("Start audio stream")
|
self.logger.info("Start audio stream")
|
||||||
await self.getStreamer().run()
|
await self.getStreamer().run()
|
||||||
|
|
Loading…
Reference in a new issue