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

- new Python 3.11 started to drop support for passing coro instead of tasks

=> coro need to be wrapped w/ tasks



git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/branches/0.7@3049 b32b6428-25c9-4566-ad07-03861ab6144f
parent e546bec0
Branches
No related tags found
No related merge requests found
......@@ -385,7 +385,7 @@ class ToolboxHelper(object):
async def find_db_server(self):
self.engine.subscribe(self.find_db_callback)
self.engine.send_is_alive(self.device, dev_types=[DB_DEV_TYPE])
await asyncio.wait([self.db_server_found.wait(), ], timeout=0.3)
await self.wait_for_event(self.db_server_found, timeout=0.3)
self.engine.unsubscribe(self.find_db_callback)
def request_db_values(self, addr):
......@@ -405,7 +405,8 @@ class ToolboxHelper(object):
# start/stop/idle/error
#####################################################
async def wait_completed(self, timeout=0.5):
await asyncio.wait([self.exit_event.wait(), ], timeout=timeout)
"""wait until exit event is set"""
await self.wait_for_event(self.exit_event, timeout=timeout)
def update_idle(self):
self.last_msg_time = now()
......@@ -445,6 +446,14 @@ class ToolboxHelper(object):
self.parser.print_help()
exit(1)
#####################################################
# misc
#####################################################
async def wait_for_event(self, event, timeout):
""" wait for a given event or timeout"""
wait_task = asyncio.create_task(event.wait())
await asyncio.wait([wait_task], timeout=timeout)
def colorize(color, text):
return f"{color}{text}{style.RESET}"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment