Skip to content
Snippets Groups Projects
Commit 3a34fb7f authored by jkerdreu's avatar jkerdreu
Browse files

- move the task removing

git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/branches/0.7@3001 b32b6428-25c9-4566-ad07-03861ab6144f
parent e059e2aa
No related branches found
No related tags found
No related merge requests found
......@@ -173,7 +173,6 @@ class AsyncEngine(core.EngineMixin):
while self.is_running():
temp = await self.__txFifo.get()
self.send_msg(temp)
await asyncio.sleep(0.001)
async def timer_task(self):
await self.running_event.wait()
......@@ -203,10 +202,17 @@ class AsyncEngine(core.EngineMixin):
self.new_task(console(locals()),name='Console')
def new_task(self,coro,name=None):
# we maintain a task list, to be able to stop/start the engine
# on demand. needed by HASS
task = self.get_loop().create_task(coro,name=name)
self._tasks.append(task)
task.add_done_callback(self.task_callback)
return task
def task_callback(self, task):
# called when a task ended
self._tasks.remove(task)
def setup_alives_timer(self):
# needed on stop-start sequence
if self.process_alives in [t.func for t in self.timers]:
......@@ -224,7 +230,6 @@ class AsyncEngine(core.EngineMixin):
if task!=self._watchdog_task:
task.cancel()
await asyncio.sleep(0.1)
self._tasks.remove(task)
def sigkill_handler(self,signal,frame):
print("", end = "\r") #remove the uggly ^C
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment