def aiohttp_start(bot, name, port, certfile, RequestHandlerClass, group, callback=None): RequestHandler = RequestHandlerClass(bot) app = web.Application() RequestHandler.addroutes(app.router) handler = app.make_handler() if certfile: sslcontext = ssl.SSLContext(ssl.PROTOCOL_SSLv23) sslcontext.load_cert_chain(certfile) else: sslcontext = None loop = asyncio.get_event_loop() server = loop.create_server(handler, name, port, ssl=sslcontext) asyncio. async (server).add_done_callback( functools.partial(aiohttp_started, handler=handler, app=app, group=group, callback=callback)) tracking.register_aiohttp_web(group)
def aiohttp_start(bot, name, port, certfile, RequestHandlerClass, group, callback=None): RequestHandler = RequestHandlerClass(bot) app = web.Application() handler = app.make_handler() RequestHandler.addroutes(app.router) sslcontext = ssl.SSLContext(ssl.PROTOCOL_SSLv23) sslcontext.load_cert_chain(certfile) loop = asyncio.get_event_loop() server = loop.create_server(handler, name, port, ssl=sslcontext) asyncio.async(server).add_done_callback(functools.partial(aiohttp_started, handler=handler, app=app, group=group, callback=callback)) tracking.register_aiohttp_web(group)