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