fix server generator coroutine issue
@@ -79,12 +79,19 @@ def plugin_start(data):
app = web.Application(middlewares=[middleware.error_middleware])
app.router.add_route('POST', '/{}'.format(uri), HttpSouthIngest.render_post)
handler = app.make_handler()
- server = loop.create_server(handler, host, port)
- asyncio.ensure_future(server)
+ server_coro = loop.create_server(handler, host, port)
+ future = asyncio.ensure_future(server_coro)
+
+ def f_callback(f):
+ # _LOGGER.info(repr(f.result()))
+ """ <Server sockets=
+ [<socket.socket fd=17, family=AddressFamily.AF_INET, type=2049,proto=6, laddr=('0.0.0.0', 6683)>]>"""
+ data['server'] = f.result()
+
+ future.add_done_callback(f_callback)
data['app'] = app
data['handler'] = handler
- data['server'] = server
except Exception as e:
_LOGGER.exception(str(e))
sys.exit(1)
