Exemple #1
0
def startapp(protocol_factory=None):
    if not protocol_factory:
        protocol_factory = ProtocolFactory()
    set_except_hook()
    args = ARGS.parse_args()

    if ':' in args.host:
        args.host, port = args.host.split(':', 1)
        args.port = int(port)

    if args.iocp:
        from asyncio import windows_events
        sys.argv.remove('--iocp')
        logging.info('using iocp')
        el = windows_events.ProactorEventLoop()
        asyncio.set_event_loop(el)

    if args.ssl:
        here = os.path.join(os.path.dirname(__file__), 'tests')

        if args.certfile:
            certfile = args.certfile or os.path.join(here, 'sample.crt')
            keyfile = args.keyfile or os.path.join(here, 'sample.key')
        else:
            certfile = os.path.join(here, 'sample.crt')
            keyfile = os.path.join(here, 'sample.key')

        sslcontext = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
        sslcontext.load_cert_chain(certfile, keyfile)
    else:
        sslcontext = None

    superviser = Superviser(args)
    superviser.start(protocol_factory, sslcontext)
Exemple #2
0
 def setUp(self):
     set_except_hook()
     from aioweb.config import set_config
     self.config = set_config(self.base_path, self.config_name)
     loggingconfig = configure_logging(self.base_path)
     test_logging(loggingconfig)
     self.loop = asyncio.new_event_loop()
     asyncio.set_event_loop(self.loop)