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

Switched to the new Async API


git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/branches/0.7@2851 b32b6428-25c9-4566-ad07-03861ab6144f
parent b5798279
No related branches found
No related tags found
No related merge requests found
from . import gw from . import gw
from xaal.lib import helpers from xaal.lib import helpers
from xaal.lib.asyncio import AsyncEngine
#helpers.run_package(gw.PACKAGE_NAME,gw.setup) helpers.run_async_package(gw.PACKAGE_NAME,gw.setup)
helpers.setup_console_logger(gw.PACKAGE_NAME)
gw.run()
from xaal.lib import tools,Device from xaal.lib import tools,Device,AsyncEngine
from xaal.lib.asyncio import AsyncEngine
from xaal.schemas import devices from xaal.schemas import devices
...@@ -102,8 +101,8 @@ class GW(object): ...@@ -102,8 +101,8 @@ class GW(object):
logger.info('Saving configuration file') logger.info('Saving configuration file')
self.cfg.write() self.cfg.write()
async def xaal_task(self): # async def xaal_task(self):
await self.engine.run() # await self.engine.run()
async def sio_task(self): async def sio_task(self):
url = self.cfg['config']['url'] url = self.cfg['config']['url']
...@@ -111,13 +110,12 @@ class GW(object): ...@@ -111,13 +110,12 @@ class GW(object):
await self.sio.wait() await self.sio.wait()
def run(): def stop():
eng = AsyncEngine() import pdb;pdb.set_trace()
def setup(eng):
gw = GW(eng) gw = GW(eng)
asyncio.ensure_future(gw.xaal_task()) eng.on_stop(stop)
asyncio.ensure_future(gw.sio_task()) eng.new_task(gw.sio_task())
loop = asyncio.get_event_loop() return True
try: \ No newline at end of file
loop.run_forever()
except KeyboardInterrupt:
print('Bye')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment